'AND' vs '&&' as operator

后端 未结 10 847
野性不改
野性不改 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:13

    Since and has lower precedence than = you can use it in condition assignment:

    if ($var = true && false) // Compare true with false and assign to $var
    if ($var = true and false) // Assign true to $var and compare $var to false
    

提交回复
热议问题