<?php
$param = 'c';
if ($param != 'a' || $param != 'b')
{
echo 'Param != a OR b';
}else
{
echo 'Param = a OR b';
}
?>
The if statement above does not work as expected because the if will ALWAYS evaluate to TRUE regardless of the value of $param.
Is there another way to construct the if statement that will work as expected (keeping the original intention… i.e. $param not being equal to a or b)?
According to De Morgan’s laws:
In your case, you have to replace the
||with the&&operator.