The php namespace usage summary can be used from php5.3. the namespace is used to prevent repeated namespace elements. Namespace elements include: class, function, and const (you can also use const to define constants outside the class starting with php5.3, but the difference between const and define is: the constant defined by define is a global constant, while the const defines a constant in the namespace );
The simplest namespace is as follows:
Namespace a; function a () {return 'aaaaaaaaaaaaaaaaa';} namespace B; function B () {return 'bbbbbbbbbbbbbbbbbbbbbb';} echo \ ();
Note: no php output code is available before the first namespace definition. why is it the first namespace? Because multiple namespaces can be defined in a file. In the preceding example, the elements (functions) in namespace a are used in namespace B );
Public space concept: what is public space? Public space is the code of the undefined namespace. it is all in public space. If an element that uses a public space in a namespace needs to use "\", for example, echo \ function ();