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
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);
What could be the reason this code doesn't work in PHP 5.6.23?
$change_text = [
"ok" => "Użytkownik zmieniony poprawnie.",
"new" => "Użytkownik dodany poprawnie.",
"delete" => "Użytkownik został usunięty.",
];
Works on my server with 5.6 and I've tested it on some other servers and it's fine. I moved a site to a new server and it has PHP 5.6.23 but this does't work...
Also the PHP documentation says:
As of PHP 5.4 you can also use the short array syntax, which replaces array() with [].
The error i get:
Parse error: syntax error, unexpected '[' in /...
Any ideas?
Sure the problem is old version of php. I had the same problem. I ran simple script with phpinfo() from browser and saw, that version is 5.6, but problem was in cli. So I checked version in cli, and It was 5.3! Thats it. ))
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.
I am programming an app locally, but when I migrate to server I get a parse error using this line:
if(!is_array($data[array_keys($data)[0]]))
Returns:
Parse error: syntax error, unexpected '[', expecting ']' in
/home/file.php
If I rewrite the line like this:
$var1 = array_keys($data);
if(!is_array($data[$varX[0]]))
It works.
What do I need to activate on server, to get it working in the first example without error?
Thanks.
You need to be running PHP version 5.4 to use array dereferencing like that. I suspect on your server you have a lower version of PHP than on your local system.
http://php.net/manual/en/migration54.new-features.php
Under 'New features':
Function array dereferencing has been added, e.g. foo()[0].
What you're trying to do is called "array dereferencing" which only became available in PHP 5.4. So if your version of PHP is earlier than that like yours is, it won't work.
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.