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.
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);
I am installed yii2 advanced template using composer all are working fine.
System have php7.1.5. Whenever i copy advanced folder in another system it throw syntax error in TestCase.php like below
Parse error: syntax error, unexpected '?' in \advanced\vendor\phpunit\phpunit\src\Framework\TestCase.php on line 822
line 822 is $configurationFilePath = $GLOBALS['__PHPUNIT_CONFIGURATION_FILE'] ?? '';
That another system have php5.6.8
So, i am directly install yii2 advanced in that system and it is working fine.
I am check TestCase.php the file have lot of differences and the particular line also changed like below
$configurationFilePath = (isset($GLOBALS['__PHPUNIT_CONFIGURATION_FILE']) ? $GLOBALS['__PHPUNIT_CONFIGURATION_FILE'] : '');
So i want to know what is going here.My question is not clear please let me know.Thanks in advance
PHP operator ?? is available since PHP7, so u can't expect, that code from PHP7 will work on server with PHP5.
PHP 7 - Null coalescing operator
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.
root#hotspot1:/var/www/httpdocs/test1.<domain>.it# curl http://getcomposer.org/installer | php
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed 100 67830 0 67830 0 0 32069 0 --
Parse error: syntax error, unexpected T_SL in /var/www/httpdocs/test1.<domain>.it/- on line 818
I cannot understand to what's referring.
I know T_SL is
<<
But, really, i've never used this token. I've this token i a third-party library, regardin Excel read/write, but it's not in the root.
I'm using php 5.2.* ob a old ubuntu 8
I read composer installer, looking for row 808. it's here the problem.
public static function getPackagedCaFile()
{
$cacert = <<<'CACERT'
But, why is it a problem?
I don't know precisely what has caused this problem, but it's plain what the basic problem is. Behat and Composer both use namespaces and other >5.3 functionality. PHP 5.2 does not recognise this syntax and cannot properly parse the file, causing the kind of error that you see above.
As the first sentence of the Behat docs says:
Behat is an open source behavior-driven development framework for PHP 5.3 and 5.4.
Or as the Composer docs say:
Composer requires PHP 5.3.2+ to run.
To uses Behat or Composer, you will need to use a modern version of PHP.
I was following this tutorial when typing up this code:
public function search($term){
$filter = function($tag) use ($term){
if(stristr($tag,$term))
return true;
return false;
};
return array_filter($this->_tags,$filter);
}
I get following errors in Zend Studio 8
syntax error, unexpected '{'
syntax error, unexpected 'function'
syntax error, unexpected 'use'
However the code works fine on my Xampp with php 5.3.1 -
How can I find the version of PHP in Zend Studio, and how can I upgrade it?
You can change the PHP version used under Window > Preferences > PHP. There you can set the PHP executable and which PHP version to use. That should allow you to find out what version you're currently using (beware that you may have overriden it in your project) and upgrade it if you'd want to.
See the Zend Studio 8 User Guide (PDF) for more information.
Preferences -> PHP ->
PHP Interpreter
PHP Executables
PHP Executables -> Execution environment
Debug