Can you set a variable in php to false?
Can this code be correct:
if($jack = "Not tall"){
$jack = FALSE;
}
if(!jack){do whatever;}
Can you set a variable in php to false?
Can this code be correct:
if($jack = "Not tall"){
$jack = FALSE;
}
if(!jack){do whatever;}
When you want to compare values, make sure to have ==
for "is equal to", or !=
"is not equal to". When you have one =
then you are setting the variable and will always evaluate as true. PHP Comparison Operators
if($jack == "Not tall"){
$jack = FALSE;
}
if(!$jack){
// do whatever ...
}
And when dealing with variables, always make sure you have the $
in the front. This is very basic php stuff.
setting a value in if statement always return true because it will return current value.
echo ($jack = "Not tall")
it will print "Not tall" so it will return true
$jack = FALSE;
it will always set false.
if($jack == "Not tall")
$jack = FALSE;
if(!jack){do whatever;}
Differences between the Equality operator (==) and the Assignment operator (=)