'AND' vs '&&' as operator

后端 未结 10 615
野性不改
野性不改 2020-11-22 02:42

I have a codebase where developers decided to use AND and OR instead of && and ||.

I know that there is a

10条回答
  •  星月不相逢
    2020-11-22 03:27

    Depending on how it's being used, it might be necessary and even handy. http://php.net/manual/en/language.operators.logical.php

    // "||" has a greater precedence than "or"
    
    // The result of the expression (false || true) is assigned to $e
    // Acts like: ($e = (false || true))
    $e = false || true;
    
    // The constant false is assigned to $f and then true is ignored
    // Acts like: (($f = false) or true)
    $f = false or true;
    

    But in most cases it seems like more of a developer taste thing, like every occurrence of this that I've seen in CodeIgniter framework like @Sarfraz has mentioned.

提交回复
热议问题