The namespace (namespace / package) is familiar to java and c # programmers, now available in php. It is necessary in order not to write long refixes to class names, as is now done in Zend, PEAR and other libraries and platforms for compatibility.
Instead, classes, functions, interfaces (abstract classes) and constants can be combined into a single namespace. Global variables are not included in this space.
Simple example
Space is determined by the namespace keyword
//
namespace MyCMS::Core;
class System{}
The use of this class in third libraries is done with the use keyword.
require_once('mycms/core.php');
use MyCMS::Core::System; //
$objSystem=new System;
As you may have guessed, the :: separator works in the same way as the static method call, separating the namespace level and the concrete class. The level of nesting of spaces can be used along with the modularity of the library, for example, to implement the spaces Database :: MySQL :: Adapter and Database :: Oracle :: Adapter.
New features and new problems
If the name of a class in the namespace overwrites a previously declared global class or function, then it can still be accessed via :: SomeClassName, but without knowing which particular implementation the programmer addresses may cause problems. For example, you can re-declare standard php functions, change sin () and cos () in places, so that someone would not seem like honey to anyone.
For debugging there is a working constant __NAMESPACE__.
The problem of ambiguity arises with a colon:
A::B() // B namespace A
A::B() // B A
Read on:
Original