【问题标题】:Smarty if statement聪明的 if 语句
【发布时间】:2012-07-18 07:48:09
【问题描述】:

我第一次使用 smarty 所以请不要作恶.. 希望有人可以帮助我解决这个问题。 我在 page.tpl 中有以下代码:

{$user-status}
{if $user-status == '-'}
    <h1>OK</h1>
{/if}

当页面加载时,我看到了

"user-status-string" // this is correct
    {if $user-status == '-'}
        <h1>OK</h1>
    {/if}

它准确地显示了我编写的代码,尽管上面显示了正确的变量属性。 有人知道我在做什么错吗?

谢谢

【问题讨论】:

    标签: php smarty smarty3


    【解决方案1】:

    我猜想用破折号命名变量可能会导致 Smarty 出现不良行为。

    例如,尝试分配和使用名为 $userStatus 的变量。

    【讨论】:

    • 缓存文件看起来正确。尝试使用 {if 'a' eq 'b'}{/if}:在缓存中 } ?> 和生成的 HTML 我看到 {if 'a' eq 'b'} {/if} !!!什么鬼?!
    • 也许检查您的编译/缓存目录位置? (与$smarty-&gt;getCompileDir()$smarty-&gt;getCacheDir()
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多