Unexpected bracket '[' - PHP [duplicate]

若如初见. 提交于 2019-11-26 19:09:34

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

Antony
$exploded = explode(".", $class);
$base = $exploded[0];

To work on older versions of PHP (<5.4), you should do:

list($base) = explode(".", $class);

That is:

list($a, $b, $c) = array(1, 2, 3);

Now $a=1, $b=2, and $c=3.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!