Am 11.12.2007 um 23:38 schrieb Stanislav Malyshev:
A simple
if(strpos($className 'My::Namespace::') === 0)
will fix that just fine.
Fix what? If you write:
namespace My::Namespace;
function foo() {
$a = new DateTime();
}
then on each call to foo() autoloader for My::Namespace::DateTime
would be called, then it would go to disk and see if there's some
file implementing that class, search all include path for it and
fail, and only then use internal DateTime. That's not "just fine".
namespace Name::Space;
class Ship {
public static function __autoload($className) {
if(strpos($className, 'Name::Space::') === 0) {
// the real deal
}
}
}
...
spl_autoload_register(array('Name::Space::Ship', '__autoload'));
No disk access. And with my suggestion to allow limiting autoloaders
to certain namespaces, it would be cut down even further.
- David
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php