syntax error, unexpected token “}”

Description

The closing curly bracket usually mark the end of a block of instructions.

When it is reported as an error, it means that the previous instruction was not closed as expected. For example, when a semi-colon was not forgotten on the previous line.

Example

<?php

// print needs a ; at the end of the command
if ($c == 3) { print 'OK'.PHP_EOL }

// The curly brackets are balanced, but not the parenthesis
if (in_array(1, [2, 4]) {}

?>

Solutions

  • Check if the previous line need a semi-colon ;.