标签:
1 <?php 2 class C_index extends Action 3 { 4 public function __initialize() 5 { 6 echo"自动执行"; 7 } 8 public function index() 9 { 10 echo "index"; 11 } 12 public function test() 13 { 14 $a="我是模板"; 15 $this->assign("pass",$a); 16 $this->display(); 17 } 18 } 19 ?>
__initialize是自动执行方法,不管路由访问哪个控制器都会,实例化这个方法。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> </head> <body> {$pass} </body> </html>
标签:
原文地址:http://www.cnblogs.com/saw2012/p/5226564.html