Reputation: 3786
if ($sess_uid == $WallID)
{
//
}
else
{
Run Action
}
Works But
if (!$sess_uid == $WallID)
{
Run Action
}
Wont work. Why is this? I want the code to fire off if both Ids don't match.
Upvotes: 4
Views: 86
Reputation: 13927
You are using the unary operator ! which only operates on the value $sess_uid. So you are negating the value of $sess_uid. What you are probably looking for is to use != instead.
if (!$sess_uid != $WallID){
Run Action
}
Upvotes: 1
Reputation: 106912
This:
if (!$sess_uid == $WallID)
{
Run Action
}
Is equivalent to this:
if ( (!$sess_uid) == ($WallID))
{
Run Action
}
While you want:
if (!($sess_uid == $WallID))
{
Run Action
}
Upvotes: 4
Reputation: 454970
!
is having higher precedence than ==
.
!a==b
is treated as (!a) == b
What you need is !(a==b)
which is same as a != b
Upvotes: 5
Reputation: 18721
if (!$sess_uid == $WallID) don't equals if ($sess_uid !== $WallID)
Upvotes: 0