worth reading for people learning about php and programming: (adding extras <?php ?> to get highlighted code)
about the following example in this page manual:
Example#1 Logical operators illustrated
...
<?php
$e = false || true; $f = false or true; var_dump($e, $f);
$g = true && false; $h = true and false; var_dump($g, $h);
?>
_______________________________________________end of my quote...
If necessary, I wanted to give further explanation on this and say that when we write:
$f = false or true; // $f will be assigned to false
the explanation:
"||" has a greater precedence than "or"
its true. But a more acurate one would be
"||" has greater precedence than "or" and than "=", whereas "or" doesnt have greater precedence than "=", so
<?php
$f = false or true;
($f = false ) or true;
$e = false || true;
is the same as
$e = (false || true);
?>
same goes for "&&" and "AND".
If you find it hard to remember operators precedence you can always use parenthesys - "(" and ")". And even if you get to learn it remember that being a good programmer is not showing you can do code with fewer words. The point of being a good programmer is writting code that is easy to understand (comment your code when necessary!), easy to maintain and with high efficiency, among other things.