abstrakt://layout.html {include file="public/header" /} {__CONTENT__} {include file="public/footer" /}//public/header.html <!doctype html> <html> <he
//layout.html {include file="public/header" /} {__CONTENT__} {include file="public/footer" /}
//public/header.html <!doctype html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <style> *{ margin: 0px; padding: 0px; } .header{ background: #000000; height: 60px; width: 100%; } .header ul{ width: 80%; height:60px; line-height: 60px; margin:0px auto; text-align: center; } .header li{ float: left; margin-left: 15px; width: 10%; list-style: none; } .header li a{ text-decoration: none; color: #EEEEEE; } </style> </head> <body> <div> <div menu> <ul> <li><a href="">首頁</a></li> <li><a href="">視頻教程</a></li> <li><a href="">社區(qū)問答</a></li> <li><a href="">技術(shù)文章</a></li> <li><a href="">編程詞典</a></li> <li><a href="">資源下載</a></li> <li><a href="">菜鳥學(xué)堂</a></li> </ul> </div> </div>
<style> .footer{ width:100%; height: 150px; background: #232323; } .footer_content{ text-align: center; color: #EEEEEE; height: 150px; line-height: 150px; font-size: 12px; } </style> <div class="footer"> <div class="footer_content"> Copyright 2014-2019 http://ipnx.cn/ All Rights Reserved | 皖B2-20150071-9 皖公網(wǎng)安備 34010402701654號(hào) 免責(zé)申明贊助與捐贈(zèng)</div> </div> </body> </html>
//控制器index <?php namespace app\index\controller; use think\Controller; class Index extends Controller { public function index() { return 'OK'; } public function demo1() { $name = 'php 中文網(wǎng)'; $this->assign('name',$name); $this->assign('name1','輸出name1'); $this->assign('name2','輸出name2'); $this->assign('name3','輸出name3'); $this->view->date='對象賦值date'; return $this->fetch(); } public function demo2() { $this->view->name='php 中文網(wǎng)'; $this->view->data='海量資源'; return $this->view->filter(function ($content){ return str_replace('php 中文網(wǎng)','歡迎來到 php中文網(wǎng)',$content); })->fetch(); } public function demo4() { return $this->view->engine->layout(true)->fetch('index/demo4'); } public function demo5() { return $this->view->engine->layout(true)->fetch('index/demo5'); } public function demo6() { return $this->view->engine->layout(true)->fetch('index/demo6'); } }
//正文部分html代碼 <style> .content{ width: 100%; height: 600px; background: #999999; } .content_up{ width: 80%; height: 600px; margin: 0px auto; background: #f8cbcb; } </style> <div class="content"> <div class="content_up"> 網(wǎng)頁demo4內(nèi)容部分 </div> </div>
<div> <style> .content{ width: 100%; height: 600px; background: #999999; } .content_up{ width: 80%; height: 600px; margin: 0px auto; background: #f8cbcb; } </style> <div class="content"> <div class="content_up"> 網(wǎng)頁demo5內(nèi)容部分 </div> </div> </div>
<div> <style> .content{ width: 100%; height: 600px; background: #999999; } .content_up{ width: 80%; height: 600px; margin: 0px auto; background: #f8cbcb; } </style> <div class="content"> <div class="content_up"> 網(wǎng)頁demo6內(nèi)容部分 </div> </div> </div>
經(jīng)過本章節(jié)學(xué)習(xí)學(xué)會(huì)了在框架中對視圖渲染,模板布局等知識(shí)??蚣荛_發(fā)技術(shù)又進(jìn)一步提升
Korrigierender Lehrer:天蓬老師Korrekturzeit:2019-06-27 13:02:01
Zusammenfassung des Lehrers:模板的寫法有很多, 可以用框架提供的引擎, 也可以直接自己寫的, 自己寫就是靈活, 完全不受框架控制, 用框架語法 , 就需要注意一些規(guī)則.......