class Printer {
function doPrint() {
echo 'hello world';
}
}
?>
function __autoload( $class ) {
$file = $class . '.class.php';
if ( is_file($file) ) {
return require_once($file);
}
}
$obj = new Printer();
$obj->doPrint();
?>
public static function loader($class){
$file = $class . '.class.php';
if(is_file($file)){
echo 'VLoader::loader<br />';
return require_once($file);
}
}
}
//spl_autoload_register(array('VLoader','loader')); //第一種調用方法,數組調用方法
spl_autoload_register('VLoader::loader'); //第二種調用方法,靜態調用方法
$p = new Printer();
$p->doPrint();