Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

No New Line In Namespaces

It was possible to use new lines inside a namespace: they would be removed at execution time, to build the actual namespace.

Since PHP 8.0, it is not allowed anymore.

PHP code

<?php

// constant
    \A 
                           \B 
                           \C
                           ;

// type
    function foo() : \A 
                           \B 
                           \C
                           {}

?>

Before

PHP Parse error:  syntax error, unexpected ';', expecting '{' 

Parse error: syntax error, unexpected ';', expecting '{' 

After

PHP Parse error:  syntax error, unexpected fully qualified name \B

Parse error: syntax error, unexpected fully qualified name \B 

PHP version change

This behavior changed in 8.0.

Error Messages

© 2023-2026, Damien Seguy - Exakat