Reputation: 177
I am unsetting the session variable by
$_SESSION = [];
this is working fine in my localhost apache server. but when i deployed my website www.mobi3.pe.hu I get the error
Parse error: syntax error, unexpected '[' in /home/u832047490/includes/functions.php on line 36
which is this line only
$_SESSION = [];
and this is not only the error if I coment it. I used a function and when return an associative array by
return [
"symbol" => $data[0],
"name" => $data[1],
"price" => $data[2],
];
I get the error
Parse error: syntax error, unexpected '[' in /home/u832047490/includes/functions.php on line 91
which is the line I mentioned earlier.
can't figure out why is this happening with square bracket. and this is happening everywhere it encounter's "[ ".. would really appreciate if one's figure out..
Upvotes: 0
Views: 574
Reputation: 41958
Short array syntax was introduced in PHP 5.4, and your hoster hasn't upgraded yet.
Run phpinfo();
to see which version is currently running.
If you need to backport your code, you can use array(...)
instead, as in:
return array("symbol" => $data[0], "name" => $data[1], "price" => $data[2]);
This is just the 'old way' of doing things.
It is also quite a good idea to kick your hoster about upgrading, since PHP 5.3 is already in its end-of-life cycle since nearly 2 years.
Upvotes: 3