logical operators or vs || (double pipe) in php -


this question has answer here:

i've used || (double pipe) if (($a == $b) || ($a == $c)) { } , or do_this() or do_that();.

why not if (($a == $b) or ($a == $c)) { } or do_this() || do_that();?

is there reason use of these 2 logical operators or personal preference?

the same applies && vs and, use &&.

the "spelled out" operators and , or have lower precedence, lower assignment, may use them avoid having write parentheses in many places. example:

$d=$a||$b , $c equivalent ($d=$a||$b) && $c

they more readable in many contexts.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -