0

Hello guys I want to know... why in this condition my int value enter in ( $var == '') condition??

my php version is 5.6

If you guys can help me find a solution... to not enter is the two conditions.

<?php

$val1 = 0;
$val2 = "0";

var_dump($val1);

echo "<BR>";

var_dump($val2);

echo "<BR>";
echo "<BR>";
echo "<BR>";

    if($val1 == ''){

        echo "val1 HERE...<BR>"; // condition Enter Here

    }

    if($val2 == ''){

        echo "val2 HERE...<BR>";

    }

?>
sealabr
  • 1,593
  • 3
  • 19
  • 28
  • 1
    Neither value is an empty string, so neither of your if statements are true. Tell me, does `"0" = ""`? – GrumpyCrouton Aug 24 '17 at 20:14
  • 3
    http://php.net/manual/en/language.operators.comparison.php - If you want to make sure val2 is an empty string and not a 0, use `===`. – aynber Aug 24 '17 at 20:16
  • 3
    http://php.net/manual/en/types.comparisons.php is a better explanation – aynber Aug 24 '17 at 20:17

0 Answers0