简单的PHP框架,实现antoload,viewEngine
最近在学写MVC框架,各位看看就好了,哈哈 br / br / PS: br / 有兴趣学写MVC框架的可以看看这篇文章: a target=_blank href=http://my.oschina.net/u/131802/blog/82016 rel=nofollowuhttp://my.oschina.net/u/131802/bl
最近在学写MVC框架,各位看看就好了,哈哈
PS:
有兴趣学写MVC框架的可以看看这篇文章: http://my.oschina.net/u/131802/blog/82016
PS:
有兴趣学写MVC框架的可以看看这篇文章: http://my.oschina.net/u/131802/blog/82016
<?php function __autoload($class){ include $class.'.php'; } $t = new tController(); $t->index();
2. [代码]Controller.php 核心控制器 跳至 [1] [2] [3] [4] [全屏预览]
<?php class Controller { function render($temple, $arr){ extract($arr); ob_start(); include $temple; $content = ob_get_contents(); ob_end_clean(); echo $content; } }
3. [代码]tController.php 普通控制器 跳至 [1] [2] [3] [4] [全屏预览]
<?php class tController extends Controller{ function index(){ $this->render('t.php', array('name'=>'aaaaaaaaaaa')); } }
4. [代码]t.php 视图文件 跳至 [1] [2] [3] [4] [全屏预览]
<html> <header> <title></title> </header> <body> <?php echo @$name; ?> <form method="post" action=""> 用户名:<input name="username" type="text" value=""><br> 密码: <input name="password" type="password"><br> <input name="submit" type="submit" value="提交"> </form> </body> </html>
精彩图集
精彩文章