daninthemix February 2016

PHP if statement - either but not both

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'])){

Answers


Neat February 2016

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

Post Status

Asked in February 2016
Viewed 2,326 times
Voted 8
Answered 1 times

Search




Leave an answer