den*_*ini 9 php arrays dereference php-5.3 php-5.5
是否有可能是这个PHP代码行
if ($this->greatestId()["num_rows"] > 0)
Run Code Online (Sandbox Code Playgroud)
在PHP 5.5中工作并在5.3中返回错误?
PHP Parse error: syntax error, unexpected '[' in /var/www/app/AppDAO.php on line 43
Run Code Online (Sandbox Code Playgroud)
如何将其更改为在PHP 5.3下工作?
Joh*_*nde 15
PHP 5.4中提供了数组解除引用这就是为什么这在PHP 5.3中不起作用的原因.所以你有一个额外的步骤,你需要从函数调用中获取数组值,然后你可以使用它:
$variable = $this->greatestId();
if ($variable["num_rows"] > 0){
// do stuff
}
Run Code Online (Sandbox Code Playgroud)
在 PHP 5.3 版本中不能像这样if ($this->greatestId()["num_rows"] > 0)使用下面的代码。
$var = $this->greatestId();
if ($var["num_rows"] > 0){
// your code
}
Run Code Online (Sandbox Code Playgroud)