Suppose I have a top-level namespace \Outer
and I have another sub-namespace \Outer\Inner
and I have another top-level namespace \Inner
and in a class in \Outer
I use Inner
like this
use Inner;
then which Inner will be used?
\Outer\Inner // ( sub-namespace )
or the
\Inner // ( top-level namespace )
I am confused because php said that the \
was optional for top-level namespaces?
When you have namespace
\Outer
in a class, thenuse Inner
is going to be usingInner
top-level namespace. If you want to use subnamespace you should use\Outer\Inner
As stated in php using namespaces
Lets say your first file was: