|
namespace keyword and __NAMESPACE__ constant
PHP supports two ways of abstractly accessing elements within the current namespace,
the
The value of Example #1 __NAMESPACE__ example, namespaced code
<?php Example #2 __NAMESPACE__ example, global code
<?php __NAMESPACE__ constant is useful for dynamically constructing
names, for instance:
Example #3 using __NAMESPACE__ for dynamic name construction
<?php The namespace keyword can be used to explicitly request an element from the current namespace or a sub-namespace. It is the namespace equivalent of the self operator for classes. Example #4 the namespace operator, inside a namespace
<?php Example #5 the namespace operator, in global code
<?php |