Parse error: syntax error, unexpected '[', expecting ')'

1Mayur picture 1Mayur · Jul 1, 2013 · Viewed 46k times · Source

I have this linecode

$media = $dc->thumbnail->attributes()['url'];

runs fine on my local (WAMP) php 5.4.3 but when i host it on my server cpanel then it gives this error

Parse error: syntax error, unexpected '[', expecting ')'

the php version on my server is 5.2.17

i dnt see any problem with it, please help

Answer

Rob W picture Rob W · Jul 1, 2013

You need to be running PHP 5.4+ to use shorthand arrays