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

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -