dump(true and false) as boolean(true)?

This question already has an answer here:

  • 'AND' vs '&&' as operator 10 answers

  • and has a lower operator precedence than = so what you are executing is:

    ($x = true) and false;
    

    So the complete expression - which you don't use the result of - will return false , but $x will be true .


    It is because the and operator does not work as you think: 'AND' vs '&&' as operator

    Basically, = has higher precedence.

    $x = false && true;
    var_dump($x);
    

    returns bool(false) .

    As does

    $x = (false and true);
    
    链接地址: http://www.djcxy.com/p/57616.html

    上一篇: 用bool表达式在PHP中分配:奇怪的行为

    下一篇: 转储(真和假)为布尔(真)?