If you are receiving an error that says “parse error: unexpected”, which of the following options can be the reason for the same?
- You have forgotten to include the opening bracket (
- You have forgotten to include the $ when referencing a variable.
- Missing a semicolon (;) at the end of an individual line.
- You have an else statement with no opening if statement.
Discussion
If you are receiving an error which says ‘parse error: unexpected’ this usually means that you have forgotten to include a character. The most common are:
Unexpected ‘=’ : you have forgotten to include the $ when referencing a variable
Unexpected ‘)’ : you have forgotten to include the opening bracket (
Unexpected ‘(‘ : you have forgotten to include the closing bracket )
Unexpected T_STRING: you have forgotten a quotation mark or a semi-colon at the end of the previous line
Unexpected T_ELSE: you have an else statement with no opening if statement