意外的支架'[' - PHP [英] Unexpected bracket '[' - PHP

查看:100
本文介绍了意外的支架'[' - PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在写我的小应用程序团队的Java code小库中,并且我有这样的错误都在我的code。

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];

只有这样的之一发生问题的code,每一次的线。据我所知,上面是正确的PHP语法,所以这是怎么回事?

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?

解析错误:语法错误,意想不到的'['以 ... / MITC / code / index.php文件 27

Parse error: syntax error, unexpected '[' in .../mitc/code/index.php on line 27

如果你想看到的错误,它在的http:// chancehenrik。 x10.mx/mitc/$c$c/ 和其他地方我的网站上。

If you'd like to see the error, it's at http://chancehenrik.x10.mx/mitc/code/ and elsewhere on my site.

推荐答案

这就是所谓的数组语法和只有作品在PHP 5.4 +。你可能运行PHP 5.3.x只要你得到这个错误。

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.

见基于不同PHP版本的结果

这篇关于意外的支架'[' - PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆