开发者

Is there any advantage to using AND and OR over && and || in PHP?

开发者 https://www.devze.com 2023-01-31 04:23 出处:网络
In the Kohana code conventions it states that using && and || is \"incorrect\": Is there a开发者_运维技巧ny advantage to using AND and OR other than clarity?The truth tables for the operato

In the Kohana code conventions it states that using && and || is "incorrect":

Is there any advantage to using AND and OR over && and || in PHP?

Is there a开发者_运维技巧ny advantage to using AND and OR other than clarity?


The truth tables for the operators are the same, the only difference is precedence:

http://php.net/manual/en/language.operators.logical.php

http://www.php.net/manual/en/language.operators.precedence.php


Just make sure that whatever convention you choose to adopt you are consistent throughout. Otherwise precedence issues will haunt your code.

0

精彩评论

暂无评论...
验证码 换一张
取 消