我总是使用||(双管)if (($a == $b) || ($a == $c)) { }和orfor do_this() or do_that();.
||
if (($a == $b) || ($a == $c)) { }
or
do_this() or do_that();
为什么不if (($a == $b) or ($a == $c)) { }和do_this() || do_that();?
if (($a == $b) or ($a == $c)) { }
do_this() || do_that();
有没有理由使用这两个逻辑运算符中的任何一个,或者只是个人偏好?
这同样适用于&&vs and,我只使用它&&.
&&
and
php logical-operators
logical-operators ×1
php ×1