syntax error, unexpected token “;”, expecting “]”

Description

A semi-colon was found after an opening square bracket. To keep the code balanced, PHP expects the bracket to be closed before finishing the instruction.

Example

<?php

[1,2; ];

$a[4;];

?>

Solutions

  • Remove the semi-colon.

  • Close the square bracket before the semi-colon.