minte9
LearnRemember



Autoload

Autoload facility allows to load classes on-demand.
 
function __autoload($class) {
    require_once str_replace("_", "/", $class);
}

$obj = new Article_Model();
The Standard PHP Library (SPL) offer a quick solution.
 
//Register an autoload function

function myAutoLoader($className) {
    include("classes/$className.php");
}

spl_autoload_register("myAutoLoader");

//Register another autoload function

function myOtherAutoLoader($className) {
    include("include/$className.php");
}

spl_autoload_register("myOtherAutoLoader");

$obj  = new MyClass1();
$obj2 = new MyClass2();  



  Last update: 471 days ago