note 98393 added to language.namespaces.rules
| From: | sammaye at osu1 dot php dot net | Date: | Sat, 12 Jun 2010 11:24:33 +0000 |
| Subject: | note 98393 added to language.namespaces.rules | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-170081@lists.php.net to get a copy of this message | ||
I have noticed one problem with __autoload function. Say you have two namespaces, one is a sub of
the other:
\Glue
\Glue\Import
Within that Import namespace you have a function auto() with the magic __autoload inside. No matter
what you do that auto() will never traverse it's sub function meaning you will nevber get an
__autoload function.
Even if you put the __autoload within a class within the namespace as such:
<?php
namespace Glue\Import;
class import{
private static $_AutoLoad = array();
private static $_Imported = array();
function load($sName){
if(! isset(self::$_AutoLoad[$sName]))
//throw new ImportError("Cannot import module with name '$sName'.");
echo("file with name '$sName' failed to load with path
'".self::$_AutoLoad[$sName]."'");
if(! isset(self::$_Imported[$sName])){
self::$_Imported[$sName] = True;
return include_once(self::$_AutoLoad[$sName]);
}
}
function push($sName, $sPath){
self::$_AutoLoad[$sName] = $sPath;
}
function auto(){
function __autoload($sClass){
load($sClass);
}
}
}
?>
It will not work. Just something to keep in mind.
----
Server IP: 208.69.120.55
Probable Submitter: 86.149.58.195
----
Manual Page -- http://www.php.net/manual/en/language.namespaces.rules.php
Edit -- https://master.php.net/note/edit/98393
Del: integrated -- https://master.php.net/note/delete/98393/integrated
Del: useless -- https://master.php.net/note/delete/98393/useless
Del: bad code -- https://master.php.net/note/delete/98393/bad+code
Del: spam -- https://master.php.net/note/delete/98393/spam
Del: non-english -- https://master.php.net/note/delete/98393/non-english
Del: in docs -- https://master.php.net/note/delete/98393/in+docs
Del: other reasons-- https://master.php.net/note/delete/98393
Reject -- https://master.php.net/note/reject/98393
Search -- https://master.php.net/manage/user-notes.php