apache - php - function()[] syntax -


this question has answer here:

i have strange syntax problem in php.

at point in code, mysql query (which send 1 line 1 value), , query result following way :

$myvar = mysql_fetch_assoc($result)["something"]; 

$result being mysql result, of course. works fine, both locally , on site. however, when colleague took latest version of site local test of own, got following error :

parse error: syntax error, unexpected '[' in c:\wamp\www\mysite\ref\myfile.php on line 33 

line 33 being line defined $myvar. fixed doing following :

$myvar = mysql_fetch_assoc($result); $myvar = $manif["something"]; 

it seems pretty obvious me problem comes wamp (i running apache server), question "why?".

i got web development (i more of c++ developer until now) , i've been using syntax while. bad practice?

and why wamp return error not apache? each server have own php parser?

thank you.

function array dereferencing (foo()[0] example) has been introduced in php5.4. check php version.


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -