Skip to main content
[(its = possessive, it's = "it is" or "it has". See for example <https://www.youtube.com/watch?v=8Gv0H-vPoDc&t=1m20s> and <https://www.wikihow.com/Use-Its-and-It%27s>.)] Loosened up. Used more standard formatting.
Source Link
Peter Mortensen
  • 31.4k
  • 22
  • 110
  • 134

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;

Its because the variable '$user_location' is not getting defined. If you are using any if loop inside which you are declaring the '$user_location' variable then you must also have an else loop and define the same. For example:

$a=10;
if($a==5) { $user_location='Paris';} else { }
echo $user_location;

The above code will create error as The if loop is not satisfied and in the else 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;
if($a==5) { $user_location='Paris';} else { $user_location='SOMETHING OR BLANK'; }
echo $user_location;

It’s because the variable '$user_location' is not getting defined. If you are using any if loop inside, which you are declaring the '$user_location' variable, then you must also have an else loop and define the same. For example:

$a = 10;
if($a == 5) { 
    $user_location = 'Paris';
}
else { 
}
echo $user_location;

The above code will create an error as the if loop is not satisfied and in the else 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;
if($a == 5) {
    $user_location='Paris'; 
} 
else {
    $user_location='SOMETHING OR BLANK'; 
}
echo $user_location;

Its because the variable '$user_location' is not getting defined. If you are using any if loop inside which you are declaring the '$user_location' variable then you must also have an else loop and define the same. For example $a=10; if($a==5) { $user_location='Paris';} else { } echo $user_location;:

$a=10;
if($a==5) { $user_location='Paris';} else { }
echo $user_location;

The above code will create error as The if loop is not satisfied and in the else 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; if($a==5) { $user_location='Paris';} else { $user_location='SOMETHING OR BLANK'; } echo $user_location;

$a=10;
if($a==5) { $user_location='Paris';} else { $user_location='SOMETHING OR BLANK'; }
echo $user_location;

Its because the variable '$user_location' is not getting defined. If you are using any if loop inside which you are declaring the '$user_location' variable then you must also have an else loop and define the same. For example $a=10; if($a==5) { $user_location='Paris';} else { } echo $user_location;

The above code will create error as The if loop is not satisfied and in the else 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; if($a==5) { $user_location='Paris';} else { $user_location='SOMETHING OR BLANK'; } echo $user_location;

Its because the variable '$user_location' is not getting defined. If you are using any if loop inside which you are declaring the '$user_location' variable then you must also have an else loop and define the same. For example:

$a=10;
if($a==5) { $user_location='Paris';} else { }
echo $user_location;

The above code will create error as The if loop is not satisfied and in the else 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;
if($a==5) { $user_location='Paris';} else { $user_location='SOMETHING OR BLANK'; }
echo $user_location;
Source Link
Roger
  • 1.7k
  • 1
  • 18
  • 34

Its because the variable '$user_location' is not getting defined. If you are using any if loop inside which you are declaring the '$user_location' variable then you must also have an else loop and define the same. For example $a=10; if($a==5) { $user_location='Paris';} else { } echo $user_location;

The above code will create error as The if loop is not satisfied and in the else 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; if($a==5) { $user_location='Paris';} else { $user_location='SOMETHING OR BLANK'; } echo $user_location;

Post Made Community Wiki by Roger