Can any one tell, will it make any difference if I use && operator for condition instead of and in my php script?
For e.g
if($i == 1 and $bool == true)
is same as
if($i == 1 && $bool == true)
It will be better if anyone tell me difference between them.
The difference between &&
and and
is precedence: &&
has a higher one.
If you evaluate boolean expressions, I would stick with the most common used: &&
and ||
.
Update:
Example:
a || b and c
evaluates as
(a || b) and c
whereas
a || b && c
evaluates as
a || (b && c)
The only difference is operator precendence, i.e if you mix and match types which ones are evaluted first.
See http://www.php.net/manual/en/language.operators.logical.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With