PHP » PYTHON |
login |
register |
about
|
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:
The same principle can be applied to namespaced elements in PHP. For example, a class name can be referred to in three ways:
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
|
more
Recently updated
more
Most requested
more
Last requests
|