请教关于smarty缓存问题,帮忙看下我这段代码为什么总报错?
include("main.inc.php");$smarty->caching=true;$smarty->cache_lifetime="60*60*123";$id...
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->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 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询