insert用于模板中。
用法:{insert name="method_name"}
此时会寻找php文件中方法名为:insert_method_name的函数,
将其返回值作为insert语句的值。
例子:
<?php
require("Smarty.class.php");
$smarty = new Smarty();
$smarty -> template_dir = "./templates"; //模板存放目录
$smarty -> compile_dir = "./templates_c"; //编译目录
$smarty -> cache_dir = "./cache"; //缓存目录
$smarty -> config_dir = "./configs"; //缓存目录 function insert_nowTime() {
return date("Y-m-d H:i:s");
} $smarty -> display('insert.tpl'); ?>
模板文件中:
<html>
<head>
<title></title>
</head>
<body> 当前时间:
{insert name="nowTime"} </body>
</html>