php中的__autoload()太鸡肋
用了__autoload(),不但不规范,反而可读性差,直接插上代码:<?php
define('TYPE',true);
function __autoload($className){
if(strtolower($className)=='t_newsa'){
include_once "model/{$className}_action.php";
}else if(strtolower($className)=='t_typea'){
include_once "model/{$className}_action.php";
}
}
$newsArr=new T_NewsA();
$typeAction=new T_TypeA();
如果不用__autoload()
则为:
<?php
define('TYPE',true);
include_once 'model/T_NewsA_action.php';
include_once 'model/T_TypeA_action.php';
include_once 'libs/Smarty.class.php';
$newsArr=new T_NewsA();
$typeAction=new T_TypeA();
页:
[1]