聪明的'OR'运算符不起作用?

use*_*187 3 html smarty

{if $command2 ne "thanks" || $command1 ne "error"}
 some code <!---Ist Code-->
{/if}

{if $command2 eq "thanks" || ($command1 eq "error"}
<meta name="Robots" content="noindex, nofollow"> <!---2nd Code-->
{/if}
Run Code Online (Sandbox Code Playgroud)

我正在尝试这个,但它没有工作.显示第一和第二代码给我一个解决方案

Emi*_*dın 5

我认为你的问题与逻辑有关.尝试&&运算符与ne案例;

{if $command2 ne "thanks" && $command1 ne "error"}
 some code <!---Ist Code-->
{/if}

{if $command2 eq "thanks" || ($command1 eq "error"}
<meta name="Robots" content="noindex, nofollow"> <!---2nd Code-->
{/if}
Run Code Online (Sandbox Code Playgroud)

这是一项基本的编程知识.反转情况时,也ORANDs 反转为s.

请记住,根据您的需要,反之亦然;

{if $command2 ne "thanks" || $command1 ne "error"}
 some code <!---Ist Code-->
{/if}

{if $command2 eq "thanks" && ($command1 eq "error"}
<meta name="Robots" content="noindex, nofollow"> <!---2nd Code-->
{/if}
Run Code Online (Sandbox Code Playgroud)

两者在不同的场景中都有意义.

更新:在您的第二个评论之后,很明显您需要在顶部的第一个示例.