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

Php {if}{else}在smarty中无法正常工作,php,smarty,smarty3,smarty2,Php,Smarty,Smarty3,Smarty2,我的模板上有以下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 {el

我的模板上有以下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}语句不起作用,总是打印值“disable UPDATE”

请尝试

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

包含空格

{capture name="diff"}{datediff timestamp=$data_base.updated_date}{/capture}
可能就是您要查找的。

我发现
{(int)$smarty.capture.diff}
打印值0,这就是它总是返回false的原因。仍在寻求帮助以解决此问题:(
{capture name="diff"}
    {datediff timestamp=$data_base.updated_date}
{/capture}
{capture name="diff"}{datediff timestamp=$data_base.updated_date}{/capture}