我有以下声明
if ( !(strstr($Description1,'word1') OR strstr($Description1,'word2') OR
strstr($Description2,'word1') OR strstr($Description2,'word2') OR
strstr($Description3,'word1') OR strstr($Description3,'word2') OR
strstr($Description4,'word2') OR strstr($Description4,'word2') OR
($_POST['fine'] == x) OR ($_POST['fine'] == y) OR ($_POST['fine'] == z))) {
Action1
} else {
Action2
}
如果任何陈述为真,它会发生什么,它会转到Action2
。我想要它做的是,如果任何陈述是真的,请转到Action1
答案 0 :(得分:0)
将“或”位保留在一组括号内 if($ a ==“a”|| $ b ==“b”){ 措施1} 否{Action2}
答案 1 :(得分:0)
为什么不在开头删除!
或只切换action1
和action2
??
if ((strstr($Description1,'word1') OR strstr($Description1,'word2') OR
strstr($Description2,'word1') OR strstr($Description2,'word2') OR
strstr($Description3,'word1') OR strstr($Description3,'word2') OR
strstr($Description4,'word2') OR strstr($Description4,'word2') OR
($_POST['fine'] == x) OR ($_POST['fine'] == y) OR ($_POST['fine'] == z))) {
Action1
} else {
Action2
}
或
if ( !(strstr($Description1,'word1') OR strstr($Description1,'word2') OR
strstr($Description2,'word1') OR strstr($Description2,'word2') OR
strstr($Description3,'word1') OR strstr($Description3,'word2') OR
strstr($Description4,'word2') OR strstr($Description4,'word2') OR
($_POST['fine'] == x) OR ($_POST['fine'] == y) OR ($_POST['fine'] == z))) {
Action2
} else {
Action1
}