Reputation: 371
How would one shorten an if statement if code is as below ?
$a = null;
$b = "foo";
if ((empty($a) && !empty($b)) || (!empty($a) && empty($b)) {}
Upvotes: 3
Views: 92
Reputation: 57121
The test seems to be checking that only 1 field contains a value, so you could check
$a = null;
$b = "foo";
if (empty($a) != empty($b)) {}
Upvotes: 5