意外的括号' [' -PHP [英] Unexpected bracket '[' - PHP
问题描述
我正在为我的小应用程序团队的Java代码编写一个小型存储库,整个代码中都出现此错误.
$base = explode(".", $class)[0];
仅在此 one 行代码中才会出现此问题.据我所知,以上是正确的PHP语法,这是怎么回事?
解析错误:语法错误, 27/b>行中的 .../mitc/code/index.php 中出现意外的'['/p>
如果您想查看该错误,请访问 http://chancehenrik.x10.mx/mitc/code/以及我网站上的其他地方.
这称为数组解引用,并且仅适用在PHP 5.4中 +.无论哪里出现错误,您都可能正在运行PHP 5.3.x.
I'm writing a small repository for my little app team's Java code, and I have this error all over my code.
$base = explode(".", $class)[0];
The problem occurs only with this one line of code, every time. As far as I know, the above is correct PHP syntax, so what's going on?
Parse error: syntax error, unexpected '[' in .../mitc/code/index.php on line 27
If you'd like to see the error, it's at http://chancehenrik.x10.mx/mitc/code/ and elsewhere on my site.
That's called array dereferencing and only works in PHP 5.4+. You're probably running PHP 5.3.x wherever you are getting that error.
See results based on different PHP versions
这篇关于意外的括号' [' -PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!