[转载]smarty 中fetch和display函数区别 – 宋红光的日志 – 网易博客.在Smarty模板函数里面有这样一个方法:fetch(“template.htm”),他和 display(“template.htm”);最大的不同就是fetch()是把内容输出给一个变量,而display()是把内容输出给浏览器,这 样我们就可以用一个变量来接收fetch()的输出,然后把他写入到文件中去.
function insert_cache($file, $display=false) {
ob_start();
if(file_exists($file)) {
include $file;
}else {
exit();
}
ob_get_contents($file);
if($display) { echo $result}
else { return $result}
}
?>
Mikel