Ajax, unexpected symbol? [duplicate] - php

This question already has answers here:
PHP syntax for dereferencing function result
(22 answers)
Closed 9 years ago.
I have this linecode
$media = $dc->thumbnail->attributes()['url'];
runs fine on my local (WAMP) php 5.4.3
but when i host it on my server cpanel then it gives this error
Parse error: syntax error, unexpected '[', expecting ')'
the php version on my server is 5.2.17
i dnt see any problem with it, please help

You need to be running PHP 5.4+ to use shorthand arrays

You can't have a php 5.4.3 and a 5.2.17 with a single WAMP installation, but from your error message, i think you are using the older one.
I guess, you are working with SimplXML. In this case, you should not use that line, anyway:
$media = $dc->thumbnail[0]['url'];
Note: $simpleXMLElement->childrenNodeListByName
& $simpleXMLElement['attributeValueByName']

Related

PHP Parse error: syntax error, unexpected '?' [duplicate]

This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 5 years ago.
I have read a lot syntax error but seldom on the error of '?'
I also saw a few post that stated this might be due to old PHP version.
So my question is does PHP5.6 isn't enough? I am using Godaddy as my host and PHP5.6 is the highest they provide.
The full error description is:
PHP Parse error: syntax error, unexpected '?' in G:\PleskVhosts\tohokiwatch.com\httpdocs\cart\vendor\illuminate\database\Eloquent\Model.php on line 579
MyPHP page stated version 5.5.30:
But my GoDaddy page stated version 5.6.30
The null coalesce operator, ?? does not exist in php 5.5 or 5.6, it was added in php 7.0

Laravel 5.3 is giving an error on production server while working fine on localhost [duplicate]

This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 6 years ago.
Laravel 5.3 is giving an error on production server while working fine on localhost. Other than changing php version, is there any other possible solution?
Parse error: syntax error, unexpected '.', expecting '&' or variable
(T_VARIABLE) in
/var/www/html/laravel_fresh/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php
on line 475
No, there is not. You need to have at least PHP >= 5.6.4 in order to run Laravel 5.3.

Unexpected '[' - no error on localhost but there is one on server [duplicate]

This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 7 years ago.
$query_var[] = '`'.array_keys($activeFilters)[$i].'` LIKE concat(\'%\',:'.array_keys($activeFilters)[$i].',\'%\')';
Parse error: syntax error, unexpected '['
So the following line generates an error in my Xampp apache server on localhost the error isn't occurring. Also on my server there was an error also with
$query_var = [];
but I changed it to $query_var = array(); and the error wanst appearing it was also a unexpected [
I am nearly sure it has something to do with the PHP version or something like that
correct, its a php version issue as of php 5.4 you can use
$query_var = [];
http://php.net/manual/en/migration54.new-features.php
so your host is running an older php version.

i have error in laravel on function /vendor/guzzlehttp/psr7/src/functions.php on line 77 [duplicate]

This question already has an answer here:
Difference in accessing arrays in PHP 5.3 and 5.4 or some configuration mismatch?
(1 answer)
Closed 7 years ago.
I upload laravel 4 files on shared server
and then i see this error.
Parse error: syntax error, unexpected '[' in . /vendor/guzzlehttp/psr7/src/functions.php on line 77
in line 77:
function stream_for($resource = '', array $options = [])
Short array syntax [] was added in PHP 5.4, so I guess you're running some older version of PHP on the shared server. Normally replacing [] with array() would help, but here it is an external vendor package so it's not advised to modify the code as changes would be overwritten when vendor package is updated. Other than that the only way to fix that issue is to use newer version of PHP.

Parse error: syntax error, unexpected '[', expecting ')' [duplicate]

This question already has answers here:
PHP syntax for dereferencing function result
(22 answers)
Closed 9 years ago.
I have this linecode
$media = $dc->thumbnail->attributes()['url'];
runs fine on my local (WAMP) php 5.4.3
but when i host it on my server cpanel then it gives this error
Parse error: syntax error, unexpected '[', expecting ')'
the php version on my server is 5.2.17
i dnt see any problem with it, please help
You need to be running PHP 5.4+ to use shorthand arrays
You can't have a php 5.4.3 and a 5.2.17 with a single WAMP installation, but from your error message, i think you are using the older one.
I guess, you are working with SimplXML. In this case, you should not use that line, anyway:
$media = $dc->thumbnail[0]['url'];
Note: $simpleXMLElement->childrenNodeListByName
& $simpleXMLElement['attributeValueByName']

Categories