简单如果其他不起作用

use*_*384 0 php if-statement

<?php
    var_dump($isHoster); // prints int(0)

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

    var_dump($conditionsHoster); // prints string(4) "0, 1"
?>
Run Code Online (Sandbox Code Playgroud)

到底是怎么回事??谁可以解释一下?这从来没有发生在我身上......

ale*_*007 6

0 == 'all'因为PHP会尝试把在PHP真正的'all'int(int) 'all'0; 你应该写

if ($isHoster === 'all')
Run Code Online (Sandbox Code Playgroud)