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">

Home  >  Article  >  Backend Development  >  关于smarty缓存有关问题

关于smarty缓存有关问题

WBOY
WBOYOriginal
2016-06-13 10:34:10708browse

关于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

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn