PHP中&&与运算符的区别

这个问题在这里已经有了答案:

  • 'AND'和'&&'作为操作符10的答案

  • “&&”的优先级高于“和”

    // The result of the expression (true && false) is assigned to $g
    // Acts like: ($g = (true && false))
    $g = true && false;
    
    // The constant true is assigned to $h and then false is ignored
    // Acts like: (($h = true) and false)
    $h = true and false;
    
    var_dump($g, $h);
    

    打印虚假,真实


    除了优先权以外,它们是相同的

    && > = > and优先表中,所以你的第一个例子等同于: ($test = true) and false;

    链接地址: http://www.djcxy.com/p/57605.html

    上一篇: Difference between && and and operator in PHP

    下一篇: PHP operator difference && and "and"