__autoload vs. spl_autoload_register

From: Date: Thu, 06 Sep 2007 22:09:48 +0000
Subject: __autoload vs. spl_autoload_register
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-47932@lists.php.net to get a copy of this message
Hi List, I'm looking at the the pear autoloader in SVN (http://svn.pear.php.net/wsvn/PEARSVN/Pyrus/trunk/src/Autoload.php?op=file&rev=0&sc=0) Wouldn't it make more sense to make use of spl_autoload_register instead? AFAIK this is a better practice because it allows multiple autoload handlers (for different libraries/directory schemes) possible. The normal __autoload also pollutes the global namespace, whereas spl_autoload_register does not. It is possible to provide a fallback, like: if (function_exists('__autoload')) spl_autoload_register('__autoload'); The only drawback is that it is possible to disable the SPL library during PHP compilation, but I don't think any sensible person would do this and I'd say its fairly safe to have SPL as a dependency for PEAR. Evert

« previous php.pear.dev (#47932) next »