You can also define multiple namespaces in the same file. Defining multiple namespaces in the same file has two syntax forms. Example #1 defines multiple namespaces, simple combination syntax Example #1 defines multiple namespaces, simple combination syntax
We do not recommend that you use this syntax to define multiple namespaces in a single file. We recommend that you use the following syntax in braces.
Example #2 define multiple namespaces, braces syntax
In actual programming practices, it is not recommended to define multiple namespaces in the same file. This method is mainly used to merge multiple PHP scripts into the same file.
The code in a global non-namespace is combined with the code in the namespace. you can only use the syntax in braces. The global code must be enclosed by a namespace statement without a name. for example:
Example #3 define multiple namespaces and code not included in the namespace
Except for the declare statement, no PHP code exists in the namespace brackets.
Example #4 define multiple namespaces and code not included in the namespace