syntax error, unexpected token “;”

Description

The semi-colon marks the end of a command. They are needed in blocks, or sequences of commands.

Here, the semi colon signals the end of the exit command, and PHP is still parsing the if condition.

Example

<?php

// 'if' needs a second closing ), but PHP keeps parsing it until the semi colon.
if ($d !== foo() {
    exit(1);
}

?>

Solutions

  • Check previous opening and closing parenthesis, they might be unbalanced.