Unexpected brute '[' - PHP
I am writing a small repository for my little Java application command code and I have this error all over my code.
$base = explode(".", $class)[0];
The problem only occurs with this one line of code each time. As far as I know, the above is the correct PHP syntax, so what's going on?
Parse error : syntax error unexpected '[' in ... / mitc / code / index.php on line 27
If you want to see the error, it's at http://chancehenrik.x10.mx/mitc/code/ and elsewhere on my site.
+3
source to share
3 answers
This is called array dereferencing and only works in PHP 5.4+ . You are probably using PHP 5.3.x wherever you get this error.
+12
source to share