Próbuję skorzystać z automatycznego ładowania w PHP. Mam różne zajęcia w różnych katalogach, a więc mam bootstrapped automatyczne ładowanie się następująco:PHP spl_autoload_register
function autoload_services($class_name)
{
$file = 'services/' . $class_name. '.php';
if (file_exists($file))
{
require_once($file);
}
}
function autoload_vos($class_name)
{
$file = 'vos/' . $class_name. '.php';
if (file_exists($file))
{
require_once($file);
}
}
function autoload_printers($class_name)
{
$file = 'printers' . $class_name. '.php';
if (file_exists($file))
{
require_once($file);
}
}
spl_autoload_register('autoload_services');
spl_autoload_register('autoload_vos');
spl_autoload_register('autoload_printers');
To wszystko wydaje się działać prawidłowo, ale po prostu chciałem, aby dokładnie sprawdzić, że to rzeczywiście jest uważana za akceptowalną praktyką.
Oto dobry artykuł na temat [jak używać spl_autoload_register do klas autoLoad w php] (http://www.webtipblog.com/using-spl_autoload_register-load-classes-php -projekt). – joe42