pauleth Posted April 16, 2008 Share Posted April 16, 2008 Hey folks, So I am hoping to find a little help with logical operators. I have this code: if (empty($roll_id) || (!empty($manufacturer) AND !empty($iso))) { //////////////// CODE GOES HERE //////////////// } I want it to work like this... If Condition 1 is TRUE OR Condition 2 is TRUE, then... Condition 1 being: empty($roll_id) Condition 2 being: !empty($manufacturer) AND !empty($iso) The code actually appears to work the way I want it to, but I'm not very familiar with order of precedence, and I was wondering if there is a better way to write it. Thanks for your assistance. Quote Link to comment https://forums.phpfreaks.com/topic/101388-logical-operators-help/ Share on other sites More sharing options...
Daniel0 Posted April 16, 2008 Share Posted April 16, 2008 You can see the operator precedence here: http://php.net/manual/en/language.operators.php#language.operators.precedence How you're doing it is perfectly fine though and probably how I would do it as well. Quote Link to comment https://forums.phpfreaks.com/topic/101388-logical-operators-help/#findComment-518555 Share on other sites More sharing options...
pauleth Posted April 16, 2008 Author Share Posted April 16, 2008 Hey Daniel, thanks a lot for the quick response. I tried to do some reading on the order or precedence online, but it was giving me a headache, haha. If the code looks okay to you, then I'll just keep it the way it is. Quote Link to comment https://forums.phpfreaks.com/topic/101388-logical-operators-help/#findComment-518568 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.