Smarty 3:如果,混合条件和运营商

sme*_*pie 0 php if-statement operators smarty conditional-statements

嗯...你能告诉我为什么这样有效:

{if !$conta|contains:"word1" && ($product->id_category_default < 388 || $product->id_category_default > 475)}
Run Code Online (Sandbox Code Playgroud)

而这不是:

{if (!$conta|contains:"word1" || !$conta|contains:"word2") && ($product->id_category_default < 388 || $product->id_category_default > 475)}
Run Code Online (Sandbox Code Playgroud)

语法错误在哪里?

Mic*_*ski 7

试试这个:

{if !($conta|contains:"word1" || $conta|contains:"word2") && ($product->id_category_default < 388 ||  $product->id_category_default > 475)}
Run Code Online (Sandbox Code Playgroud)