意外的括号 '[' - PHP [英] Unexpected bracket '[' - PHP

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

问题描述

我正在为我的小应用团队的 Java 代码编写一个小型存储库,但我的代码中到处都是这个错误.

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

问题只出现在这一行代码中,每次.据我所知,以上是正确的 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/code/ 和我网站上的其他地方.

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天全站免登陆