note 96010 added to language.namespaces.nsconstants

From: Date: Wed, 03 Feb 2010 02:24:54 +0000
Subject: note 96010 added to language.namespaces.nsconstants
Groups: php.notes 
Request: Send a blank email to php-notes+get-165611@lists.php.net to get a copy of this message
Just in case you wonder what the practical use of the namespace keyword is... It can explicitly refer to classes from the current namespace regardless of possibly "use"d classes with the same name from other namespaces. However, this does not apply for functions. Example: <?php namespace foo; class Xyz {} function abc () {} ?> <?php namespace bar; class Xyz {} function abc () {} ?> <?php namespace bar; use foo|Xyz; use foo|abc; new Xyz(); // instantiates \foo\Xyz new namespace|Xyz(); // instantiates \bar\Xyz abc(); // invokes \bar\abc regardless of the second use statement |foo|abc(); // it has to be invoked using the fully qualified name ?> (Sorry, I had to use "|" instead of "\", as it was always discarded in the preview, except within a comment.) Hope, this can save someone from some trouble. Best regards. ---- Server IP: 85.214.154.209 Probable Submitter: 77.189.134.195 ---- Manual Page -- http://www.php.net/manual/en/language.namespaces.nsconstants.php Edit -- https://master.php.net/note/edit/96010 Del: integrated -- https://master.php.net/note/delete/96010/integrated Del: useless -- https://master.php.net/note/delete/96010/useless Del: bad code -- https://master.php.net/note/delete/96010/bad+code Del: spam -- https://master.php.net/note/delete/96010/spam Del: non-english -- https://master.php.net/note/delete/96010/non-english Del: in docs -- https://master.php.net/note/delete/96010/in+docs Del: other reasons-- https://master.php.net/note/delete/96010 Reject -- https://master.php.net/note/reject/96010 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#165611) next »