6.14. Namespaces
Naming variables, functions, and classes is difficult. Aside from the artistic process of finding a name that communicates purpose, you must worry whether the name is used anywhere else. Within the context of a short script, this second problem is elementary. When you consider reusing your code, any future project must avoid using your names. Generally, reusable code finds itself inside functions or classes, which takes care of many variable name conflicts. But functions and classes may find themselves in conflict with duplicate names. You can try to avoid this situation by adding prefixes to the names of all classes you create, or you can use a namespace statement.
The namespace statement gives a name to a block of code. From ...
Get Core PHP Programming, Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.