日期:2014-05-16  浏览次数:20420 次

PHP框架的制作原理

index.php 主入口文件

<?php
? define('ISEXIST',true);
? require "init.php";
? $control = new Controller();
? $control -> Run();
?>
---------------------------------------------------------------------------------------------

init.php 文件

<?php
? if(!defined('ISEXIST'))
? ?exit("请从入口文件运行程序");
? header("Content-Type:text/html;charset=utf-8");
??
? if(!defined('ROOT_PATH'))
? ?//这里动态的声明,'\\'是转义反斜线,默认'\'为转义字符
? ?define('ROOT_PATH',str_replace('\\','/',dirname(__FILE__)));?
? require ROOT_PATH.'/a/config.php';
? require ROOT_PATH.'/a/controller.class.php';
? require ROOT_PATH.'/a/view.class.php';
? require ROOT_PATH.'/a/model.class.php';
??
?>
----------------------------------------------------------------------------------------------

config.php 文件

<?php
? if(!defined('ISEXIST'))
? ?exit("请从入口文件运行程序");
? $C = array(