[PEPr] Comment on PEAR::NameScheme
| From: | PEPr | Date: | Sun, 06 Jun 2004 11:53:43 +0000 |
| Subject: | [PEPr] Comment on PEAR::NameScheme | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-30021@lists.php.net to get a copy of this message | ||
Dmitry Koteroff (http://pear.php.net/user/koteroff) has commented on the proposal for
PEAR::NameScheme.
Comment:
Some comments about PHP5's __autoload() usage:
[code]class PEAR_NameScheme_Autoload {
# static void classAutoloader(string $classname)
static function classAutoloader($classname) {
$fname = PEAR_NameScheme::name2path($classname);
if ($f = @fopen($fname, "r", true)) {
fclose($f);
return include_once($fname);
}
return false;
}
}
...
fuction __autoload($cls) {
return PEAR_NameScheme_Autoload::classAutoloader($cls);
}
[/code]
Here $classname is ALWAYS passed in lowercase, so we need to manually search for class file in
include_path. PEAR_NameScheme helps. (PEAR_NameScheme_Autoload is not proposed now, it is used here
as example.)
Proposal information:
http://pear.php.net/pepr/pepr-proposal-show.php?id=82
--
Sent by PEPr, the automatic proposal system at http://pear.php.net