user1711384 user1711384 - 2 years ago 78
PHP Question

Simple If else is not working

var_dump($isHoster); // prints int(0)

if ($isHoster == 'all')
$conditionsHoster = '0, 1';
$conditionsHoster = intval($isHoster);

var_dump($conditionsHoster); // prints string(4) "0, 1"

What is going on?? Who can explain that?
This never happened to me...

Answer Source

0 == 'all' is true in php because php tries to convert 'all' to int and (int) 'all' is 0; you should write

if ($isHoster === 'all')
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download