syntax error, unexpected token “;”, expecting “,” or “)”

Description

The declare instruction was not finished properly. declare accepts one or more paramter. With one parameter, the instruction must be closed with a closing parenthesis after the value expression; with multiple parameters, the parameters are separated by commas ,, and the last parameter is followed by a closing parenthesis.

This error message is dedicated to declare, as similar other syntaxes yield distinct error messages.

Example

<?php

declare(strict_types=1;

?>

Solutions

  • Add a closing parenthesis between the 1 and the semi-colon ;.

  • Add a comma after the 1, provide another parameter, and close the declare with a closing parenthesis.