zoukankan      html  css  js  c++  java
  • syntax error, unexpected '['

    在用ThinkPHP框架做了个小的应用
    我在本地搭建的服务器,进行测试好着的。
    但是放到别的地方后,出现以下报错
    syntax error, unexpected '['
    错误位置是在我自己写的一个Action文件中,错误代码是这样的:
    PHP code?
    1
    $user M('userinfo_table')->where($data)->select()[0];

    当我将这段代码修改成下面的之后,就没有报错了:
    PHP code?
    1
    2
    $user M('userinfo_table')->where($data)->select();
    $userinfo $user[0];

    这个是什么原因呢,代码里面只要有这样的数组就出问题了,求


    解决方法
    你的php版本不够高,不支持第一种写法。
    $user M('userinfo_table')->where($data)->select()[0];
    需要 php5.4 及以上
  • 相关阅读:
    jQuery效果
    jQuery事件
    jQuery安装和基础语法
    html5响应式布局
    html5新特性--音频视频,拖放
    js-浏览器DOM
    js-Array
    js-Date
    js-String
    Cocoa touch(五):UIControl
  • 原文地址:https://www.cnblogs.com/lxwphp/p/7731257.html
Copyright © 2011-2022 走看看