Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 564
1Mayur Avatar asked Jul 01 '13 18:07

1Mayur


People also ask

How do I fix parse error syntax error unexpected?

How To Fix parse error syntax error unexpected ' ' in wordpress Via FTP? In order to fix the Syntax Error in WordPress you need to edit the code that caused this error. The only possible way to resolve the syntax error is to directly exchange the faulty code via FTP or access the file you last edited using FTP.

What is parse error syntax error unexpected?

A parse error: syntax error, unexpected appears when the PHP interpreter detects a missing element. Most of the time, it is caused by a missing curly bracket “}”. To solve this, it will require you to scan the entire file to find the source of the error.

What is parse error in PHP?

If the PHP code contains a syntax error, the PHP parser cannot interpret the code and stops working. For example, a syntax error can be a forgotten quotation mark, a missing semicolon at the end of a line, missing parenthesis, or extra characters.


1 Answers

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

like image 131
Rob W Avatar answered Oct 20 '22 16:10

Rob W