代碼 application\index\controller\index.php
<?php namespace app\index\controller; use app\index\controller; class Index extends IndexBase { public function index() { return $this->fetch(); } public function base () { return $this->fetch(); } }
模板application\index\view\index\index.html
{extend name="index/base" /} {block name="title"} Title: {/block} {block name="right"} 最新資訊: {/block} {block name="footer"} {__block__}@ThinkPHP 版權所有 {/block}
模板application\index\view\index\base.html
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>{block name="title"}標題{/block}</title> </head> <body> {block name="menu"}菜單{/block} {block name="left"}左邊分欄{/block} {block name="main"}主內容{/block} {block name="right"}右邊分欄{/block} {block name="footer"}底部{/block} </body> </html>
輸出結果:菜單 左邊分欄 主內容 最新資訊: 底部@ThinkPHP 版權所有
注意:{__block__}