<?php
function loadModel($class) {
$path = $DOCUMENT_ROOT . '/models/';
require_once $path . $class .'.php';
}
function loadView($class) {
$path = $DOCUMENT_ROOT . '/views/';
require_once $path . $class .'.php';}
}
spl_autoload_register('loadModel');
spl_autoload_register('loadView');
<?php
spl_autoload_register(function ($class_name) {
include $class_name . '.php';
});
$obj = new MyClass1();
$obj2 = new MyClass2();
?>