note 119970 added to language.namespaces.importing

From: Date: Fri, 30 Sep 2016 10:53:10 +0000
Subject: note 119970 added to language.namespaces.importing
Groups: php.notes 
Request: Send a blank email to php-notes+get-206710@lists.php.net to get a copy of this message
Note that "use" importing/aliasing only applies to the current namespace block. <?php namespace SuperCoolLibrary { class Meta { static public function getVersion() { return '2.7.1'; } } } namespace { use SuperCoolLibrary\Meta; echo Meta::getVersion();//outputs 2.7.1 } namespace { echo Meta::getVersion();//fatal error } ?> To get the expected behavior, you'd use: class_alias('SuperCoolLibrary\Meta','Meta'); ---- Server IP: 72.52.91.14 Probable Submitter: 209.134.120.141 ---- Manual Page -- http://php.net/manual/en/language.namespaces.importing.php Edit -- https://master.php.net/note/edit/119970 Del: integrated -- https://master.php.net/note/delete/119970/integrated Del: useless -- https://master.php.net/note/delete/119970/useless Del: bad code -- https://master.php.net/note/delete/119970/bad+code Del: spam -- https://master.php.net/note/delete/119970/spam Del: non-english -- https://master.php.net/note/delete/119970/non-english Del: in docs -- https://master.php.net/note/delete/119970/in+docs Del: other reasons-- https://master.php.net/note/delete/119970 Reject -- https://master.php.net/note/reject/119970 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#206710) next »