Possible Duplicate:
PHP - and / or keywords
I saw several bits of PHP code using or in a way I was unfamiliar with. For example:
fopen($site,"r") or die("Unable to connect to $site");
Is this equal to this ||?
Why would you use this instead of a try catch block? What will cause the program run the or die()?
It is for the most part, but...
The reason for the two different variations of "and" and "or" operators is that they operate at different precedences.
See http://php.net/manual/en/language.operators.logical.php
or is equal to || except that || has a higher presedense than or.
Reference:
http://www.php.net/manual/en/language.operators.precedence.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