<?php
$contestant_one='best teeth';
$contestant_two='best ears';
if($contestant_one xor $contestant_two){
print("We have just one winner.");
}
else{
print("Both can't win!");
}
echo "\r\n----------\r\n";
$contestant_one='best teeth';
$contestant_two='';
if($contestant_one xor $contestant_two){
print("We have just one winner.");
}
else{
print("Both can't win!");
}
Output:
Both can't win!
----------
We have just one winner.
PS: Note that the "both can't win" message would also display if both variables were empty, so the message could be misleading in this case.