vendredi 24 juin 2016

IF Condition return true for the 0 compared to string in PHP

I faced the below scenario that happened with my web application. I need a exact reason and solution for this

<?php
$var = 0;
if ($var == "StringVal") {
    echo $var;
    echo "Wrong";
} else {
    echo "Right";
}
?>

these code must print

Right

, But it print

0Wrong

What are the possibilities of this problem ?

Aucun commentaire:

Enregistrer un commentaire