I recently did the blog tutorial for CakePHP, as is found here: http://book.cakephp.org/2.0/en/tutorials-and-examples/blog/blog.html
I have CakePHP version 2.8.5, and WampServer with Apache 2.4.9, PHP 5.5.12 and MySQL 5.6.17, and got the blog running on localhost/.
I am now trying to upload the blog to a server online, and have used SmartFTP to upload files to the folder public_html on a free web server online, but when I visit the domain, I receive:
Parse error: syntax error, unexpected T_STATIC, expecting T_STRING or T_VARIABLE or '$' in /home/a3087838/public_html/lib/Cake/Core/App.php on line 221
Line 221 is:
if (!empty(static::$legacy[$type])) {
which is part of:
public static function path($type, $plugin = null) {
if (!empty(static::$legacy[$type])) {
$type = static::$legacy[$type];
}
I have seen similar questions asked online, but the solution seems to be that PHP version 5.3 or greater is required as prior versions don't support late static binding, but my version is 5.5.12, so I shouldn't have that problem.
I tried replacing the word static with self, but the error then just reiterates itself for later lines containing static. I repeated this down to line 282 and it's behaviour didn't change. I could replace all other instances of static with self, but that will take a while and I expect there is a better solution that I am missing, if that is even a solution. I am inexperienced and any help would be appreciated.
Related
OS: macOS Big Sur
PHP version: 7.4.1
Package name and version: google/apiclient: ^2.12.3
Whenever I switch the PHP version to 7.4.1 I get this error
Parse error: syntax error, unexpected 'static' (T_STATIC) in /Users/webtechstreet4/Local Sites/fvtest/app/public/wp-content/plugins/form-vibes-pro/vendor/psr/cache/src/CacheItemInterface.php on line 75
The library works great on PHP 8 but gives the above error when switching to PHP 7.
Screenshot
Actually, I sorted it out by changing the system PHP version and running composer update.
I thought I needed to change the site PHP version but it was actually the system PHP version.
here is the GitHub issue link: https://github.com/googleapis/google-api-php-client/issues/2246
it is because, static return type is available only for PHP 8, I have same issue, just for temporary you can change
.\vendor\psr\cache\src\CacheItemInterface.php
line number 75 just remove return type static like this
public function set($value);
This question already has answers here:
PHP unexpected '['
(1 answer)
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 6 years ago.
I'm using Slim Framework, and have set-up a very simple API to retrieve data from a database. This works flawlessly on my local machine, OS X El Capitan.
But - when moving the files to a shared hosting environment, all the routes throw 500 errors, with this error specifically:
Parse error: syntax error, unexpected '['
vendor/nikic/fast-route/src/functions.php on line 12
Line 12 is:
function simpleDispatcher(callable $routeDefinitionCallback, array $options = []) {
I can't work out why it is throwing a parse error on this line, and why it works on my local but not on shared, both running a version of PHP 5.5. Does anybody have any ideas on why this could be?
You are using an old PHP version in your server which doesn't properly support Slim router. You should upgrade to PHP 5.5 according to the minimum requirements of slim framework. [] style arrays do not work in older versions of PHP, hence the error message.
You need to replace the array declaration with the older style like this:
function simpleDispatcher(callable $routeDefinitionCallback, array $options = array()) {
And on all other occurrences in your code. Or if possible, just upgrade the PHP version that'll eventually support square brackets as array declaration syntax.
I'm trying to install codeigniter bonfire. After clicking the install button on the create username screen, it takes a few moments and then it loads this page. I watched some tutorials on how to install bonfire so I know this isn't what I should be seeing.
Regardless, I updated the RewriteBase to /bonfire/ as it says..and now I'm getting this error when I try to go to localhost/bonfire/index.php
Parse error: syntax error, unexpected 'yield' (T_YIELD), expecting
identifier (T_STRING) in
/opt/lampp/htdocs/bonfire/bonfire/application/libraries/template.php
on line 305
Here's the code at line 305
public static function yield()
{
$output = '';
if (self::$debug) { echo 'Current View = '. self::$current_view; }
self::load_view(self::$current_view, NULL, self::$ci->router->class .'/'. self::$ci->router->method, FALSE, $output);
Events::trigger('after_page_render', $output);
return $output;
}//end yield()
I found this link on bonfire forums explaining the error.
Bonfire forums link
It says to use PHP 5.4 and that's what I'm using. My operating system is Linux Zorin and I'm using lampp, so I'm not sure if this could be a permissions issue.
thx in advance and please let me know if you need more info.
a bit late but hopefully help.
You can change the name for static function yield in cibonfire, something like this:
public static function yield()
to:
public static function yield_content()
this works perfectly to me.
I think in the LAMP the version of PHP is 5.5 + Something. IN PHP 5.5 there is a function name as yield so you have to downgrade your LAMP PHP version to 5.4 or modify in the Bonfire file system.
For change in Bonfire You can Go through this link and your problem has been solved.
https://github.com/illuminate/view/commit/d37abcecc7d79d00bf5f22b134d152ca765f26b2
You can also Review this link Laravel 4 syntax error out-of-the-box
I just installed Laravel 4 (Illuminate) and as I opened the index.php file in a browser, I was met with this error:
Parse error: syntax error, unexpected 'yield' (T_YIELD), expecting identifier (T_STRING) in /www/Laravel4/vendor/illuminate/view/src/Illuminate/View/Environment.php on line 339
I have fixed the permissions for the meta folder, and installed all the dependencies through Composer. I am running PHP version 5.5.0alpha2 on OSX 10.8.2.
That's because yield became a language construct in PHP 5.5 (used in Generators) - but someone decided that it's a good idea to use this short word to name a function:
public function yield($section)
{
return isset($this->sections[$section]) ? $this->sections[$section] : '';
}
Downgrade to PHP 5.4 (after all, it's the current mainstream version, 5.5 is not even in beta yet) and it should work fine.
I made this stupidly simple PHP file containing
<?php
class stuff {
private $var;
}
?>
and results in this error when run:
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in . . . on line 4
To make things even more confusing, it functions normally on a different domain with the same host. Surely the folder and domain have nothing to do with whether class properties can be defined. What is going on here??
That's legal PHP code. I'd guess you're testing it in a machine that has PHP 4 installed. Support for PHP 4 has been discontinued for a long time; it's strongly recommended to upgrade.
Seems like PHP 4 is active on that particular domain/folder of yours.
It looks like php4.
put
<?php phpinfo();>
into a file and view it from a web browser. That will let you determine the version.
You mean a different domain hosted on the same server? It could be an error with your php installation.