Your conditional expression logic has unnecessary redundancy. You are performing a full string comparison and to determine if a string is spain
or not, you only need one condition. (USA's got nothing to do with the logic.)
$location = 'spain';
if ($location != 'spain') {
echo 'Not Spain';
} else {
echo 'This is Spain';
}
If you wish to determine if the string is spain
or usa
and output an accurate response, using ==
comparisons and add an elseif
expression.
$location = 'spain';
if ($location == 'spain') {
echo 'This is Spain';
} elseif ($location == 'usa') {
echo 'This is USA';
} else {
echo 'This is neither Spain, nor USA';
}