Namespaces¶
In PHP, namespaces are a way to encapsulate items like classes, interfaces, enumerations, traits, functions, and constants, preventing naming conflicts between different parts of a program. They help organize and structure code, especially in larger projects where multiple developers may be contributing.
<?php
namespace a {
class x {
}
}
namespace b {
// a second class x, although distinct from the previous one
class x {
}
}
?>
See also Understanding PHP Namespaces: Organising Your Code
Related : Use Alias, Fully Qualified Name
Added in PHP 5.3