The Namespace Stack¶
<?php
namespace {
const A = 'in \\';
}
namespace A {
const A = 'in A';
}
namespace A\B {
const A = 'in A\\B';
}
namespace A\B\C {
echo A;
}
This is a reminder that namespaces are not nested, but are merely prefixes. Hence, there is the current namespace, and the global one for the occasional fallback, but nothing in between. Namespaces are not folders, even when they are stored as such.
See Also¶
PHP Features¶
Last updated: 14 July 2026