I have Apache/PHP/MySQL installed locally on my computer to quickly test stuff out. One of the things I'm currently working on is a hexagon chart for a statistics in a game created dynamically via the GD library.
On my laptop everything worked OK as I'm getting a nice result.
However when I deploy it onto the server I bought I'm getting a syntax error:
Parse error: syntax error, unexpected '['
Coming from this statement:
$hexstat = new CL2HexStatPoints(
CL2StatsRepository::GetClassesFromJson()[$id], <- *error here*
new CHexagon( CVector2::Create( constant("RADIUS"), constant("RADIUS") )
)
);
It doesn't seem to like the index operator on there. The function itself parses a json file and returns an array of objects containing properties about player classes. I've confirmed that it is indeed an array by using var_dump. However if I program it like this:
$array = CL2StatsRepository::GetClassesFromJson();
var_dump( $array[$id] ); // this is ok
var_dump( CL2StatsRepository::GetClassesFromJson()[$id] ); // this isn't
The first statement is OK, the second one isn't. The version of PHP I have on my work computer is 5.4.12 and the version of PHP on the server is 5.3.22. I'm assuming something has changed involving the operator between version or there is maybe a setting I need to change. I haven't really been able to find any information either searching around, is there anybody that could perhaps shed some light on why this is? Thanks a lot.
EDIT: I've fixed the code to be compatible with the old PHP version so I'll keep that in mind from now on. If anybody is interested in seeing it work for real: http://www.qzmpox.nl/l2/hexagon/hexagontest.php