syntax error, unexpected token “#[”, expecting “]”

Description

It is not possible to nest attributes, so the first attribute must be finished, with a closing square bracket, before opening the second one.

Example

<?php

#[A
#[B]
class X {}

?>

Solutions

  • Close the first attribute with a closing square bracket.

  • Remove the extra opening #[ attribute, and use a comma.