Smarty - 如何使用比较数字
Smarty - how to use comparison numbers
我正在这样做:
{if $categories->id !=86 && $categories->id !=87}
xxxx code
{/if}
categories
是一个vector
,id从1到140左右,id的86和87存在,我不想在id为86的页面上做代码和 87,但它无法正常工作。
这将始终执行,因为当您在类别 86 中时,它的计算结果为:
if (true && false) // returns false
您需要使用 XOR 运算符
{if $categories->id !=86 xor $categories->id !=87}
xxxx code
{/if}
编辑
抱歉错过了 dont wan't to execute part
{if !($categories->id ==86 || $categories->id ==87)}
xxx code
{/if}
应该没问题
我正在这样做:
{if $categories->id !=86 && $categories->id !=87}
xxxx code
{/if}
categories
是一个vector
,id从1到140左右,id的86和87存在,我不想在id为86的页面上做代码和 87,但它无法正常工作。
这将始终执行,因为当您在类别 86 中时,它的计算结果为:
if (true && false) // returns false
您需要使用 XOR 运算符
{if $categories->id !=86 xor $categories->id !=87}
xxxx code
{/if}
编辑
抱歉错过了 dont wan't to execute part
{if !($categories->id ==86 || $categories->id ==87)}
xxx code
{/if}
应该没问题