<?php function __autoload($class){ include $class.'.php'; } $t = new tController(); $t->index();
<?php class Controller { function render($temple, $arr){ extract($arr); ob_start(); include $temple; $content = ob_get_contents(); ob_end_clean(); echo $content; } }
<?php class tController extends Controller{ function index(){ $this->render('t.php', array('name'=>'aaaaaaaaaaa')); } }
<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>