Php 智能if语句

Php 智能if语句,php,smarty,smarty3,Php,Smarty,Smarty3,我第一次使用smarty所以请不要作恶。。 希望有人能帮我解决这个问题。 我在page.tpl中有以下代码: {$user-status} {if $user-status == '-'} <h1>OK</h1> {/if} {$user status} {如果$user status=='-'} 好啊 {/if} 当页面加载时,我看到 "user-status-string" // this is correct {if $user-status =

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

{$user-status}
{if $user-status == '-'}
    <h1>OK</h1>
{/if}
{$user status}
{如果$user status=='-'}
好啊
{/if}
当页面加载时,我看到

"user-status-string" // this is correct
    {if $user-status == '-'}
        <h1>OK</h1>
    {/if}
“用户状态字符串”//这是正确的
{如果$user status=='-'}
好啊
{/if}
虽然上面显示了正确的变量属性,但它显示的代码与我编写的代码完全相同。 有人知道我做错了什么吗


谢谢

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


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

我想用破折号命名变量可能会导致Smarty出现不必要的行为


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

缓存文件看起来正确。尝试使用{if'a'eq'b'}{/if}:在缓存和生成的HTML中我看到{if'a'eq'b'}{/if}!!!我勒个去?!也许可以检查编译/缓存目录位置?(使用
$smarty->getCompileDir()
$smarty->getCacheDir()
)缓存文件看起来是正确的。尝试使用{if'a'eq'b'}{/if}:在缓存和生成的HTML中我看到{if'a'eq'b'}{/if}!!!我勒个去?!也许可以检查编译/缓存目录位置?(使用
$smarty->getCompileDir()
$smarty->getCacheDir()