|
Using namespaces: BasicsBefore discussing the use of namespaces, it is important to understand how PHP knows which namespaced element your code is requesting. A simple analogy can be made between PHP namespaces and a filesystem. There are three ways to access a file in a file system:
Here is an example of the three kinds of syntax in actual code: file1.php
<?php file2.php
<?php Note that to access any global class, function or constant, a fully qualified name can be used, such as \strlen or \Exception or \INI_ALL. Example #1 Accessing global classes, functions and constants from within a namespace
<?php |