I have a set of code that runs only if two variables are set and each variable is a particular string. What is the best way to word the if conditions?
The code should run
if neworder and newperson are set if neworder == 'yes' and neworder == 'yes'
if($_POST['neworder'] == "yes" AND $_POST['newperson'] == "yes") { //code here }
Oh my word! What a brain fart! I know that. I've been sitting here working too long. I need a break.
Thanks for your help. 🙂
One other quick question, I'm used to using && instead of AND to join two conditions. Is either better than the other?
For the most part, the two are the same. "AND" is a logical operator (man page: [man]operators.logical[/man]) whereas "&&" is a comparison operator (man page: [man]operators.comparison[/man]).
Here's a quote from the PHP manual:
The reason for the two different variations of "and" and "or" operators is that they operate at different precedences. (See Operator Precedence.)