index.tpl:
<div>{insert name="get_current_time"}</div>index.php
<?php
require_once ("./libs/Smarty.class.php");
function insert_get_current_time(){
return date("Y-m-d H:m:s");
}$smarty = new Smarty();
$smarty->template_dir = './templates/';
$smarty->compile_dir = './templates_c/';
$smarty->config_dir = './configs/';
$smarty->cache_dir = './cache/';
$smarty->cache_lifetime =2;
$smarty->caching = true;
if(!$smarty->is_cached()){
echo "你好";
}$smarty->display(index.tpl);?>
if(!$smarty->is_cached())这个语句报错
Warning: Missing argument 1 for Smarty::is_cached(), called in D:\AppServ\www\smarty\index.php on line 20 and defined in D:\AppServ\www\smarty\libs\Smarty.class.php on line 984
<div>{insert name="get_current_time"}</div>index.php
<?php
require_once ("./libs/Smarty.class.php");
function insert_get_current_time(){
return date("Y-m-d H:m:s");
}$smarty = new Smarty();
$smarty->template_dir = './templates/';
$smarty->compile_dir = './templates_c/';
$smarty->config_dir = './configs/';
$smarty->cache_dir = './cache/';
$smarty->cache_lifetime =2;
$smarty->caching = true;
if(!$smarty->is_cached()){
echo "你好";
}$smarty->display(index.tpl);?>
if(!$smarty->is_cached())这个语句报错
Warning: Missing argument 1 for Smarty::is_cached(), called in D:\AppServ\www\smarty\index.php on line 20 and defined in D:\AppServ\www\smarty\libs\Smarty.class.php on line 984
解决方案 »
- SMTP Error: Could not connect to SMTP host.
- json foreach,如何分别获取每一个坐标值?
- dedecms5.6 整站上传后找不到主页
- PHP的fopen()函数给出的几种文件模式中的读模式和读写模式到底有什么区别?
- 请教PHP查询语句
- 寻求WEB项目合作伙伴,编程高手一名。。
- 正则表达式,截取字符串
- 怪事!同一条sql语句在php和在mysql命令行下查询得到不同的结果!
- 刚下了一个php-5.0.0RC3-Win32,不知道怎么装,请指教
- 变量未定义?怎么搞的?在线等待...谢谢!
- 关于升级PHP,我现在在用的PHP是v4.4.4,好象是直接安装带Php.exe
- php中分页怎么分啊?求教
is_cached()至少需要一个参数
例如:
<?php
$smarty->caching = true;if(!$smarty->is_cached('index.tpl')) {
// do database calls, assign vars here
}$smarty->display('index.tpl');
来源:smarty 参考手册
http://smarty.php.net/manual/en/api.is.cached.php
?>