PHP
downloads | documentation | faq | getting help | mailing lists | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Namespace definition> <Type Hinting
Last updated: Fri, 22 Aug 2008

view this page in

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.



add a note add a note User Contributed Notes
Namespaces
There are no user contributed notes for this page.

Namespace definition> <Type Hinting
Last updated: Fri, 22 Aug 2008
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites