caching=true; $smarty->cache_lifetime="60*60*123"; $id=$_GET['id']; $mysqli=new mysqli("localhost&quo"/> caching=true; $smarty->cache_lifetime="60*60*123"; $id=$_GET['id']; $mysqli=new mysqli("localhost&quo">

关于smarty缓存有关问题

WBOY
发布: 2016-06-13 10:34:10
原创
712 人浏览过

关于smarty缓存问题
include("main.inc.php");
$smarty->caching=true;
$smarty->cache_lifetime="60*60*123";
$id=$_GET['id'];
$mysqli=new mysqli("localhost","root","123456","test");
$query="select * from user where id=$id";
if(!$smarty->is_cached("demo2.tpl",$id))
{
echo "sfd";
$result=$mysqli->query($query);
$arr=$result->fetch_assoc();
$smarty->assign("arr",$arr);
}

//如果不设置display的第二个参数,显然每次只会只读取缓存你文件,这不是我们想要看的结果
//$smarty->display("demo2.tpl");
//启用多页面的缓存
$smarty->display("demo2.tpl",$id);
?>
为什么会报错,,

Fatal error: Uncaught exception 'SmartyException' with message 'Call of unknown method 'is_cached'.' in D:\server\Apache2.2\htdocs\sutra\Smarty\sysplugins\smarty_internal_templatebase.php:755 Stack trace: #0 [internal function]: Smarty_Internal_TemplateBase->__call('is_cached', Array) #1 D:\server\Apache2.2\htdocs\sutra\smart\demo2.php(8): Smarty->is_cached('demo2.tpl', '19') #2 {main} thrown in D:\server\Apache2.2\htdocs\sutra\Smarty\sysplugins\smarty_internal_templatebase.php on line 755


------解决方案--------------------
请检查你的 smarty 的版本号
is_cached 方法只适用于 smarty 3
对于 smarty 2 是 isCached

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!