PHP spl_autoload_register

0 Cevap php

PHP autoloading yararlanmak için çalışıyorum. Ben farklı dizinlere çeşitli sınıfları var, ve aşağıdaki gibi ben autoloading önyükleyicisini var:

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');

Her iyi iş gibi görünüyor, ama ben sadece bu gerçekten kabul edilebilir bir uygulama olarak kabul edilir olmadığını kontrol çift istedim.

0 Cevap