What's the correct way to rephrase this statement so that it passes if either variable is set, but not if BOTH are set?
if (isset($_GET['txnid']) || isset($_GET['complete'])){
PHP provides an alternate syntax for the || operator — the or operator. It also provides an alternate syntax for && operator — the and operator. These operators have the advantage of making our code more human readable.
The comparison operator called Equal Operator is the double equal sign “==”. This operator accepts two inputs to compare and returns true value if both of the values are same (It compares only value of variable, not data types) and return a false value if both of the values are not same.
PHP Conditional Statements if statement - executes some code if one condition is true. if...else statement - executes some code if a condition is true and another code if that condition is false. if... elseif...else statement - executes different codes for more than two conditions.
Yes, its called an XOR, it will be true if either one of them is true, but not both.
if (isset($_GET['txnid']) XOR isset($_GET['complete'])){
Source: PHP: Logical Operators
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