Here is an example of what I'm trying to do:
<?php echo $Main->GetInfo()['Players'] . '/' . $Main->GetInfo()['MaxPlayers']; ?>
On Localhost, this works perfectly. When I upload it to a web server though, I get this message:
Parse error: syntax error, unexpected '[', expecting ',' or ';' in /usr/www/.../header.php on line 111
Why does this happen? I can not change GetInfo()
to $GetInfo
as it'll return undefined.
In localhost you're using PHP 5.4, in your server the version is 5.3 or less, so you can't use that syntax.
More info: http://php.net/manual/en/migration54.new-features.php
In PHP 5.3 you should use:
<?php
$info = $Main->GetInfo();
echo $info['Players'] . '/' . $info['MaxPlayers'];
?>