有没有人试过smarty手册上的这个例子,我原样copy,居然不对

helloyou0 2005-04-14 08:35:53

我试的结果是每次都一样

-------------------------------------
Example 14-11. Preventing a whole passage of a template from being cached

例14-11.阻止一个模板文件的整篇被缓存

index.php:

require('Smarty.class.php');
$smarty = new Smarty;
$smarty->caching = true;

function smarty_block_dynamic($param, $content, &$smarty) {
return $content;
}
$smarty->register_block('dynamic', 'smarty_block_dynamic', false);

$smarty->display('index.tpl');


index.tpl:

Page created: {"0"|date_format:"%D %H:%M:%S"}

{dynamic}

Now is: {"0"|date_format:"%D %H:%M:%S"}

... do other stuff ...

{/dynamic}



When reloading the page you will notice that both dates differ. One is "dynamic" one is "static". You can do everything between {dynamic}...{/dynamic} and be sure it will not be cached like the rest of the page.

当重新加载这个页面,你将会注意到这两个日期不同。一个是“动态“,一个是“静态”。你能够在{dynamic}...{/dynamic}之间作任何事情,并且保证它将不会像剩下的页面一样被缓存。

...全文
132 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
helloyou0 2005-04-16
  • 打赏
  • 举报
回复
居然没人要分?
helloyou0 2005-04-15
  • 打赏
  • 举报
回复
嗯,是这个参数的问题,cache_modified_check如果为true就不行。


进来的接分
helloyou0 2005-04-14
  • 打赏
  • 举报
回复
我的时间每次刷新前后一样,不像它说的那样第一个是创建时间,第二个是当前时间。
看上去就象都缓存了一样。
Meteorlet 2005-04-14
  • 打赏
  • 举报
回复
我测试过是可以的,到底什么地方不对?
helloyou0 2005-04-14
  • 打赏
  • 举报
回复
为什么呢?
allkill 2005-04-14
  • 打赏
  • 举报
回复
挺多错误的。
我原来就修正了好几个。

21,882

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧