Home > Backend Development > PHP Tutorial > ThinkPHP出错syntax error, unexpected '['求解答

ThinkPHP出错syntax error, unexpected '['求解答

WBOY
Release: 2016-06-13 12:11:08
Original
1638 people have browsed it

ThinkPHP报错syntax error, unexpected '['求解答
在用ThinkPHP框架做了个小的应用
我在本地搭建的服务器,进行测试好着的。
但是放到别的地方后,出现以下报错
syntax error, unexpected '['
错误位置是在我自己写的一个Action文件中,错误代码是这样的:

$user = M('userinfo_table')->where($data)->select()[0];
Copy after login

当我将这段代码修改成下面的之后,就没有报错了:
<br />$user = M('userinfo_table')->where($data)->select();<br />$userinfo = $user[0];<br />
Copy after login

这个是什么原因呢,代码里面只要有这样的数组就出问题了,求解决方法 
谢谢各位了
------解决思路----------------------
你的php版本不够高,不支持第一种写法。
------解决思路----------------------
$user = M('userinfo_table')->where($data)->select()[0];
需要 php5.4 及以上

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template