Referencia del lenguaje
PHP Manual

Namespaces

Table of Contents

Namespaces overview

Namespaces in PHP are designed to solve scoping problem in large PHP libraries. In PHP, all class definitions are global. Thus, when a library author creates various utility or public API classes for the library, he must be aware of the possibility that other libraries with similar functionality would exist and thus choose unique names so that these libraries could be used together. Usually it is solved by prefixing the class names with an unique string - e.g., database classes would have prefix My_Library_DB, etc. As the library grows, prefixes add up, leading to the very long names.

The namespaces allow the developer to manage naming scopes without using the long names each time the class is referred to, and solve the problem of shared globals space without making code unreadable.

Namespaces are available in PHP as of PHP 5.3.0. This section is experimental and subject to changes.


Referencia del lenguaje
PHP Manual