syntax error, unexpected token “namespace”, expecting “{”

Description

The namespace token is one of the first to be used in a script. There is little other command that can be used outside a namespace.

Example

<?php

namespace A

namespace B;

?>

Solutions

  • Check the previous namespace command, and its final semi colon.

  • Check the previous namespace command, and its associated block.