2013-05-07 61 views
-2

我只是想知道如何我可以得到success回声没有改变我的if (.....)条件。我是否需要添加更多条件或任何函数或数组?只是一个小混乱写现在谢谢。只是想知道这是否会以这种方式工作或我必须写大码这个条件:)与&&,!=和||有一点混淆在php

$petbuyer1 = 1; 
$petbuyer2 = 2; 
$petbuyer3 = 3; 
$user_id = 1; 
$petfom = "fomyes"; 
$fomon = "fomyes"; 

if (($petfom == $fomon) && ($user_id == $petbuyer1 || $user_id == $petbuyer2 || $user_id == $petbuyer3)) { 
    echo "failed"; 
}else{ 
    echo "success"; 
} 

也试过:

if (($petfom == $fomon) && ($user_id != $petbuyer1 || $user_id != $petbuyer2 || $user_id != $petbuyer3)) { 
    echo "failed"; 
}else{ 
    echo "success"; 
} 
+1

请阅读['in_array'](http://php.net/manual/en/function.in-array.php) – PeeHaa 2013-05-07 17:14:57

+1

你有一个错字 - 变量被声明为'$ fomom',但已被使用作为'$ fomon' – PinnyM 2013-05-07 17:14:57

+0

它不清楚你想要什么。我也注意到你有$ fomom =“fomyes”;但你正在与$ fomon进行比较。可能变量名称是不一样的? – dee 2013-05-07 17:15:18

回答

2

好像与$fomom一个错字错误。可能是它应该是$fomon

+0

是的谢谢:)我觉得它 – deerox 2013-05-07 17:17:47