这是我正在尝试做的一个例子:
<?php echo $Main->GetInfo()['Players'] . '/' . $Main->GetInfo()['MaxPlayers']; ?>
Run Code Online (Sandbox Code Playgroud)
在Localhost上,这非常有效.当我将其上传到Web服务器时,我收到此消息:
Parse error: syntax error, unexpected '[', expecting ',' or ';' in /usr/www/.../header.php on line 111
Run Code Online (Sandbox Code Playgroud)
为什么会这样?我无法改变GetInfo(),$GetInfo因为它将返回undefined.
在localhost中,您使用的是PHP 5.4,在您的服务器中,版本为5.3或更低,因此您无法使用该语法.
更多信息:http://php.net/manual/en/migration54.new-features.php
在PHP 5.3中,您应该使用:
<?php
$info = $Main->GetInfo();
echo $info['Players'] . '/' . $info['MaxPlayers'];
?>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
54 次 |
| 最近记录: |