Every class and function in a namespace can be referred to by the full name - e.g. MyProject::DB::Connection or MyProject::DB::connect - at any time.
Example #1 Using namespaced name
$x = new MyProject::DB::Connection;
Namespaces can be imported into current context (global or namespace) using the use operator. The syntax for the operator is:
/* ... */
use Some::Name as Othername;
// The simplified form of use:
// which is the same as :
use Foo::Bar as Bar;
use can be used only in global scope, not inside function or class. Imported names have effect from the point of import to the end of the current file. It is recommended to put imports at the beginning of the file to avoid confusion.
Example #2 Importing and accessing namespace
use MyProject::DB::Connection as DbConnection;
$x = new MyProject::DB::Connection();
$y = new DB::connection();
$z = new DbConnection();
Note: The import operation is compile-time only, all local names are converted to their full equivalents by the compiler. Note that it won't translate names in strings, so callbacks can't rely on import rules.