diff --git a/language/namespaces.xml b/language/namespaces.xml index 17009d022a..611e480229 100644 --- a/language/namespaces.xml +++ b/language/namespaces.xml @@ -592,7 +592,8 @@ $b = namespace\CONSTANT; // assigns value of constant CONSTANT to $b PHP namespaces support - two kinds of aliasing or importing: aliasing a class name, and aliasing a namespace name. + three kinds of aliasing or importing: aliasing a class name, aliasing an interface name, + and aliasing a namespace name. Note that importing a function or constant is not supported. @@ -610,13 +611,13 @@ use My\Full\Classname as Another; use My\Full\NSname; // importing a global class -use \ArrayObject; +use ArrayObject; $obj = new namespace\Another; // instantiates object of class foo\Another $obj = new Another; // instantiates object of class My\Full\Classname NSname\subns\func(); // calls function My\Full\NSname\subns\func $a = new ArrayObject(array(1)); // instantiates object of class ArrayObject -// without the "use \ArrayObject" we would instantiate an object of class foo\ArrayObject +// without the "use ArrayObject" we would instantiate an object of class foo\ArrayObject ?> ]]> @@ -624,7 +625,7 @@ $a = new ArrayObject(array(1)); // instantiates object of class ArrayObject Note that for namespaced names (fully qualified namespace names containing namespace separator, such as Foo\Bar as opposed to global names that do not, such as FooBar), the leading backslash is unnecessary and not - allowed, as import names + recommended, as import names must be fully qualified, and are not processed relative to the current namespace.