- <?php
- /**
- * 基础的架构,不要轻易动。
- *
- */
- class Base
- {
- function Base()
- {
- extract($_GET);
- if (!isset($module)||$module=='')
- {
- $module='index';
- }
- if (!isset($act)||$act=='')
- {
- $act='index';
- }
- if (!file_exists('module/'.$module.'/'.$act.'.act.php'))
- {
- exit('module/'.$module.'/'.$act.'.act.php文件不存在,请在对应位置创建类文件。');
- die();
- }
- include('module/'.$module.'/'.$act.'.act.php');
- return new $act;
- }
- }
- /**
- * 解析模板函数,将值传到模板中来显示
- *
- * @param unknown_type $tplName 需要拿的模板名称
- * @param unknown_type $key 变量的名字
- * @param unknown_type $value 变量的值
- */
- function tpl($tplName,$key='',$value='')
- {
- header("Content-Type:text/html; charset=utf-8");
- if ($key=='')
- {
- include('tpl/'.$tplName);
- }
- else
- {
- $$key = $value;
- include('tpl/'.$tplName);
- }
- }
- //该片段来自于http://www.codesnippet.cn/detail/1912201411345.html
来源: http://www.codesnippet.cn/detail/1912201411345.html