smarty 模板 引入文件

来源:互联网 发布:java项目介绍ppt 编辑:程序博客网 时间:2024/05/23 02:23

b.php

<?php
include("../init.inc.php");

$title="smarty学习";
$content="smarty模板的介绍";

//分配变量
$tpl->assign("title",$title);
$tpl->assign("content",$content);



//调用模板文件
//./tpl/a.html
$tpl->display("./tpl1/a.tpl");

?>

a.tpl

<html>
 <head>
   <title>   <{$title}>   </title>
   <link rel="stylesheet" href="../css/*.css">
 </head>
 <body>
  <img src="../tpl/tpl1/1.jpg" >
   <i>      <{$content}>   </i>
 </body>
</html>


init.inc.php

<?php
require ("../libs/Smarty.class.php");
define('ROOT','D:/wamp/www/smartyMB/smarty/');
//创建模板对象
$tpl = new Smarty();
$tpl->template_dir    = ROOT.'tpl';
$tpl->compile_dir     = ROOT.'tpl_c';
$tpl->left_delimiter  = '<{';
$tpl->right_delimiter ='}>';

?>

下载smarty模板


原创粉丝点击