PHP 5.3.10与PHP 5.5.3语法错误意外'[' [英] PHP 5.3.10 vs PHP 5.5.3 syntax error unexpected '['

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

问题描述

难道这个PHP code线

Is it possible that this PHP code line

if ($this->greatestId()["num_rows"] > 0)

工作在PHP 5.5和5.3返回一个错误??

works in PHP 5.5 and returns an error in 5.3??

PHP Parse error:  syntax error, unexpected '[' in /var/www/app/AppDAO.php on line 43

我怎样才能改变它的PHP 5.3下工作?

How can I change it to work under PHP 5.3?

推荐答案

阵解引用在PHP 5.4起可用这就是为什么这并不在PHP 5.3工作。所以,你有你需要从你的函数调用获取数组值一个额外的步骤,然后你可以使用它:

Array dereferencing became available in PHP 5.4 That's why this doesn't work in PHP 5.3. So you have an extra step where you need to get the array value from your function call and then you can use it:

$variable = $this->greatestId();
if ($variable["num_rows"] > 0){
      // do stuff
}

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

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