Re: Re: class_is_loadable?

From: Date: Sat, 05 Jul 2008 20:30:00 +0000
Subject: Re: Re: class_is_loadable?
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-276319@lists.php.net to get a copy of this message
On Saturday 05 July 2008 2:25:20 pm Pulni4kiya wrote: > First of all, I don't think using autoload is recommended. Why not? I know there is a performance hit for the lookup time, but for the system I'm working on I have already solved that issue with selective pre-caching. > If you really want to do it that way, you could check if the file which > autoload will try to include exists and if it does, include it and create > your object. Well yes, but then I'm not using autoload at all. I may as well just include_once() and class_exists(), which is what I'm trying to avoid, both for code cleanliness and performance (include_once() has its own performance issues). > Actually to make the script more safe, after including the file you should > check if the class exists (because the file might exist but not have the > class in it) and only then you can make the object of that class. > > I suppose you could throw the exception you want and do it with the > try-catch as you like it :) Again, that's basically just reimplementing autoloading in user-space, which defeats the purpose. If I know exactly which autoload routine would be responsible for loading a given class, can I do the check in that autoload routine and throw an exception there? Or would that make insanity happen? :-) -- Larry Garfield larry@garfieldtech.com

« previous php.general (#276319) next »