So I just did some random test and understand the fundamentals of Precedence and the || and or operators but I'm having trouble understanding why $f changes:
$f = 0 || 1;
if ($f === 1){
echo "TRUE - $f";
}else{
echo "FALSE - $f";
}
$f = 0 or 1;
if ($f === 0){
echo "TRUE - $f";
}else{
echo "FALSE - $f";
}
Thanks for some insight.
It's normal to evaluate always to
True
. The reason is that OR means if that one of the values is True it will take this one.Update to your new question:
The answer is that "||" has a greater precedence than "or"
You can learn more at the PHP manual website here which I found this example