abstrakt:一、php代碼<?php//Composer引入Smarty模板引擎require __DIR__ . '/config/config.php';//渲染demo.html頁面$smarty->display('demo.html');二、demo.html前端頁面{* 引入模板文件 *}{extends file="layout.html&q
一、php代碼
<?php
//Composer引入Smarty模板引擎
require __DIR__ . '/config/config.php';
//渲染demo.html頁面
$smarty->display('demo.html');
二、demo.html前端頁面
{* 引入模板文件 *}
{extends file="layout.html"}
{* 頭部 *}
{block name="header"}
{$smarty.block.parent}
<h1 style="color:red">,我是頭部</h1>
{/block}
{* 主體 *}
{block name="content"}
{$smarty.block.parent}
<h1 style="color:red">,我是主體</h1>
{/block}
{* 尾部 *}
{block name="footer"}
{$smarty.block.parent}
<h1 style="color:red">,我是尾部</h1>
{/block}
三、.layout.html模板頁面
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{block name="title"}模板繼承案例{/block}</title>
</head>
<body>
{block name="header"}
1.你好
{/block}
{block name="content"}
2.你好
{/block}
{block name="footer"}
3.你好
{/block}
</body>
</html>
四、運行效果
Korrigierender Lehrer:查無此人Korrekturzeit:2019-05-05 09:15:54
Zusammenfassung des Lehrers:完成的不錯。學(xué)習(xí)php,就要多了解幾種框架。繼續(xù)加油。