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
解决方案 »
- 请问url中的index.php?action/method/key/value是如何实现的?
- 一个网站项目的 基本开发流程
- 求一个..htaccess urlrewrite
- 注册用户时出现“Warning: mysql_num_rows(): supplied argument is not a valid MySQL ...
- 如何实现字符串递增?
- 在PHP世界中选择最合适的模板--比较PHPLIB Template和FastTe
- 文字链接问题
- 关于mysql数据库导入的问题(通过sql导入,但是又有2进制文件..)
- 新浪正直播盖次讲话。
- 一个模糊查询的问题,数据库用的是mysql,答对者100分相送?
- 关于升级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
?>