代码写法上的用户体验可以更好,可以考虑

浏览:724 发布日期:2013/04/11
class IndexAction extends Action {
    public function index(){
            $this->assign('demo','hello');
            $this->assign('demo2','hello2');
            $this->display('index');
    }
}
这种写法有颇多值得改进的地方。$this->assign('demo','hello')
              ->assign('demo2','hello2')
              ->display('index');
看起来好吧?
$this->display('index');也可以改进,调用模板嘛,这回后缀倒省了,书写节省了时间,哈哈~但是不直观,
$this->display('index.html');不是更好?
模板都在Tpl文件夹下,Tpl可以省略不写了,不用考虑相对路径,
模板放哪就调用哪里,
例如
$this->display('index/index.html');
$this->display('index/public/index.html');
评论(
后面还有条评论,点击查看>>