I have a variable called root. The value for this variable is 0
$root = 0;
if($root == "readmore"){
$root = 1701;
}
somehow for some weird reason if $root is 0 it still enteres the if statement above? I have no idea what it could be
This is because, with type-juggling,
0is considered equal to"readmore". You are asking PHP to compare a string to an integer, and it will interpret any string that doesn’t contain digits as a0.If you use
if ($root === "readmore") ..., PHP will check the type as well as the value of the variable.