smarty 中2个时间怎么对比早晚

2025-02-27 17:16:39
推荐回答(3个)
回答1:

@set_time_limit(10000);//页面运行时间10000秒

php缓存页面一般是指像smarty或smarttemplate

这样用编译原理做模板功能的

php代码中的一个功能

像SmartTemplate是将模板语言{var1} 换成

并将改后的代码存入另一个文件中,在templates文件夹中

以后如果原文件没有改动过就用上次编译的文件,

来节省编译花去的时间

所以

怎么设置php缓存页面的时间?

要看你用了哪个模板引擎

smarty:改法
require('Smarty.class.php');
$smarty = new Smarty;

$smarty->caching = true;//开启缓存
$smarty->cache_lifetime = 300;缓存时间为300秒

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

SmartTemplate的改法
$template = new SmartTemplate('template.html');
$template->lifttime=3000;
$text = 'Sample Text';
$template->assign( 'TITLE', $text );
$template->output();
?>

回答2:

和PHP中的一样
可以直接 {if $timea >$timeb}$timeb早{else}...{/if}

回答3:

比如$row.updated是最后更新时间, 如果1分钟内更新的打印TRUE ,
{if $smarty.now - $row.updated < 60 }TRUE{/if}

这么写就可以了