ItsIt’s because the variable '$user_location''$user_location' is not getting defined. If you are using any if loopif loop inside, which you are declaring the '$user_location' variable, then you must also have an else loopelse loop and define the same. For example:
$a=10;$a = 10;
if($a==5$a == 5) {
$user_location='Paris';} $user_location = 'Paris';
}
else {
}
echo $user_location;
The above code will create an error as The if loopthe if loop is not satisfied and in the else loopelse loop '$user_location' was not defined. Still PHP was asked to echo out the variable. So to modify the code you must do the following:
$a=10;$a = 10;
if($a==5$a == 5) {
$user_location='Paris';
}
else {
$user_location='SOMETHING OR BLANK';
}
echo $user_location;