復制代碼 代碼如下:
<?php
class abc{
function __construct()
{
echo 'www.chhua.com;
}
}
?>
復制代碼 代碼如下:
<?php
class LOAD
{
static function loadClass($class_name)
{
$filename = $class_name.".class.php";
if (is_file($filename)) return include_once $filename;
}
}
/**
* 設置對象的自動載入
* spl_autoload_register — Register given function as __autoload() implementation
*/
spl_autoload_register(array('LOAD', 'loadClass'));
$a = new Test();//實現自動加載,很多框架就用這種方法自動加載類
?>
新聞熱點
疑難解答