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

Spaces In Namespaces

It used to be valid syntax to have a new line or a space in a namespace name. This is not the case in PHP 8.0 anymore.

PHP code

<?php

namespace Vendor
\Package;

echo 1;

?>

Before

1

After

PHP Parse error:  syntax error, unexpected fully qualified name "\Package", expecting "{" 

Parse error: syntax error, unexpected fully qualified name "\Package", expecting "{" 

PHP version change

This behavior changed in 8.0.

Error Messages

Extension

© 2023-2026, Damien Seguy - Exakat