---
title: "Declare php array as javascript array situation"  
description: "Declare php array as javascript array situation"  
author: "Mark Devid"  
published: 2013-05-15  
updated: 2013-05-15  
canonical: https://www.mindstick.com/forum/890/declare-php-array-as-javascript-array-situation  
category: "php"  
tags: ["php"]  
reading_time: 1 minute  

---

# Declare php array as javascript array situation

Hi [Expert](https://www.mindstick.com/articles/13120/an-expert-financial-advice-will-improve-your-finances)!\
I was unable to find an answer to this situation that I have stumbled uppon this morning. I have declared some php [variables](https://www.mindstick.com/articles/715/php-variables) as I usually do in [javascript](https://www.mindstick.com/articles/874/how-to-create-watermark-text-for-textbox-by-using-javascript) (by [mistake](https://yourviews.mindstick.com/view/88393/ai-humanity-s-greatest-invention-or-final-mistake)). I was surprised that the code actually worked. I have tested it under Linux and it [works fine](https://answers.mindstick.com/qa/115732/my-software-works-fine-on-windows-10-but-crashes-on-windows-11-why). Under WAMP on [Windows](https://www.mindstick.com/articles/311752/how-to-install-and-use-the-google-wifi-software-on-a-windows-or-mac-computer) does not work.\
The code:\
<?php\
error_reporting(E_ALL);\
$phones = [];\
var_dump($phones);\
?>[Result](https://www.mindstick.com/blog/12011/advantages-of-getting-result-oriented-seo-from-an-agency) in Linux:\
array(0) {}Result in Windows:\
Parse error: [syntax error](https://www.mindstick.com/forum/159599/what-is-a-syntax-error-in-sql-give-an-example), unexpected '[' in D:\wamp\www\test.php on line 7[Question](https://www.mindstick.com/blog/23175/how-to-solve-neet-question-paper-in-less-time): Is this a valid declaration of an array in php?\
Thanks in [advance](https://www.mindstick.com/blog/33258/jee-mains-and-jee-advance-exams)! \

## Replies

### Reply by AVADHESH PATEL

Hi Mark!\
The [] syntax is valid only in PHP 5.4 or newer, check your PHP version on windows.\
I hope it helpful for you.


---

Original Source: https://www.mindstick.com/forum/890/declare-php-array-as-javascript-array-situation

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
