is it possible to have a solution that works like an autoloader... for example:
$myclass = new class();
but if this class wasn't loaded yet, it loads by itself... egg:
if(class_exists(class))
{
$myclass = new class();
}
else
{
require_once(PATH_DIR.'class.class.php');
$myclass = new class();
}
PHP5 has a callback for just this purpose.
A special function named __autoload() is called whenever an attempt is made to instantiate an undeclared class. The function should then define the needed class.
I've been using it for months without any issue.
I just did a search and was suprised to see it's missing from the docs at php.net. It's mentioned on zend.com though:
http://www.zend.com/php5/articles/engine2-php5-changes.php#Heading19
--Rick