Declare php array as javascript array situation -
i unable find answer situation have stumbled uppon morning. have declared php variables in javascript (by mistake). surprised code worked. have tested under linux , works fine. under wamp on windows not work.
the code:
<?php error_reporting(e_all); $phones = []; var_dump($phones); ?>
result in linux:
array(0) { }
result in windows:
parse error: syntax error, unexpected '[' in d:\wamp\www\test.php on line 7
question: valid declaration of array in php?
php 5.4.0 offers wide range of new features: read more
short array syntax has been added,
e.g.
$a = [1, 2, 3, 4]; or $a = ['one' => 1, 'two' => 2, 'three' => 3, 'four' => 4];
above syntax not supported below versions 5.4.0. according understanding might running different versions of php in linux & windows. use phpinfo()
check php versions.
Comments
Post a Comment