php – {if} {else}在smarty中无法正常工作

发布时间:2022-04-30 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了php – {if} {else}在smarty中无法正常工作脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
我在我的模板上有以下智能代码

{capture name="diff"}
    {datediff timestamp=$data_base.updated_date}
{/capture}

{$smarty.capture.diff} | {$smarty.const.UPDATE_BLOCK_SECONDS}

{if $smarty.capture.diff > $smarty.const.UPDATE_BLOCK_SECONDS}
    enable update
{else}
    disable update
{/if}

当我打印变量$smarty.capture.diff和$smarty.const.UPDATE_BLOCK_SECONDS时,它们输出正确的值(例如98969和86400),但{if}语句不起作用并始终打印值“禁用更新”

解决方法

请试试

{if 0+$smarty.capture.diff > 0+$smarty.const.UPDATE_BLOCK_SECONDS}
  enable update
{else}
  disable update
{/if}

要么

{if (int)$smarty.capture.diff > (int)$smarty.const.UPDATE_BLOCK_SECONDS}
  enable update
{else}
  disable update
{/if}

脚本宝典总结

以上是脚本宝典为你收集整理的php – {if} {else}在smarty中无法正常工作全部内容,希望文章能够帮你解决php – {if} {else}在smarty中无法正常工作所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。