May 7, 2013
Just little bit confusion with && , != and || in php
Deerox’s Questions:
I am just wondering how i can get success
as echo without changing my if (.....)
condition. do i need to add more condition or any function or an array? just a lil confused write now thanks. Just want to know if it will work this way or i have to write big codes for this condition 🙂
$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";
}
Also tried :
if (($petfom == $fomon) && ($user_id != $petbuyer1 || $user_id != $petbuyer2 || $user_id != $petbuyer3)) {
echo "failed";
}else{
echo "success";
}
Seems like a typo error with $fomom
. May be it should be $fomon
.