function __autoload($name){
require './lib/'.$name.'.class.php';
}
//注册用于自动加载的函数
spl_autoload_register("model");
spl_autoload_register("controll");
//分别定义两个函数
function model($name){
$file = './model/'.$name.'.class.php';
if(file_exists($file)){
require './model/'.$name.'.class.php';
}
}
//如果需要一个类,但当前页面还没加载该类
//就会依次调用model()和controll(),直到找到该类文件加载,否则就报错
function controll($name){
$file = './controll/'.$name.'.class.php';
if(file_exists($file)){
require './controll/'.$name.'.class.php';
}
}
//若注册的是方法而不是函数,则需要使用数组 spl_autoload_register( //非静态方法 array($this,'model'), //静态方法 array(__CLASS__,'controller') );
//自动加载
//控制器类 模型类 核心类
//对于所有的类分为可以确定的类以及可以扩展的类
spl_autoload_register('autoLoad');
//先处理确定的框架核心类
function autoLoad($name){
//类名与类文件映射数组
$framework_class_list = array(
'mySqldb' => './framework/mySqldb.class.php'
);
if(isset($framework_class_list[$name])){
require $framework_class_list[$name];
}elseif(substr($name,-10)=='Controller'){
require './application/'.PLATFORM.'/controller/'.$name.'.class.php';
}elseif(substr($name,-6)=='Modele'){
require './application/'.PLATFORM.'/modele/'.$name.'.class.php';
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有