Please help me with this error:

Parse error: syntax error, unexpected '[' in /var/www/user/data/www/sayt.ru/index.php on line 33

Here are the 33 lines:

if (array_key_exists("p", $_GET) && in_array($_GET["p"], ["admin", "password-reset"])) { 

PHP Version 5.3.28

  • PHP which version? - Dmitriy Simushev
  • one
    Try in_array($_GET["p"], array("admin", "password-reset") - aleks.andr
  • php 5.1-5.6, so it is written on reg.ru - JackWolf
  • @JackWolf, in PHP5.1 and PHP5.6 your code will work differently . Without specifying a specific version you can not help (telepaths do not count). - Dmitriy Simushev
  • @Dmitriy Simushev, here I found: 5.3.28 - JackWolf

1 answer 1

PHP 5.3.x does not have short syntax for arrays. So, the design

 ["admin", "password-reset"] 

not valid

Use instead

 array("admin", "password-reset") 

For reference:

The abbreviated syntax for defining arrays appeared only in PHP 5.4.0

  • Thanks, it was decided, but another error occurred, I will try to fix it ... - JackWolf
  • hah, solved the problem, just changed php, but thanks anyway! - JackWolf