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

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

问题描述

有没有可能是这个PHP代码行

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 vs PHP 5.5.3 语法错误意外的“["的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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