I have the following code and don't think and is needed, i.e. &&
should be used, as there is nothing to assign the left part to?
if($_REQUEST['foo'] != 'abc' and $_REQUEST['bar'] == 'def')
{
echo "all your base";
}
So it should be:
if($_REQUEST['foo'] != 'abc' && $_REQUEST['bar'] == 'def')
{
echo "all your base";
}
Answer
In your case, &&
and and
do the same thing, but take a look at the operator precedence. You can see that &&
and and
are not on the same level, so mixing that could give you unexpected results in some cases - I recommend always using &&
, but that's your choice.
No comments:
Post a Comment