Home » Php » naming conventions – Is there any advantage to using AND and OR over && and || in PHP?

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

Posted by: admin July 12, 2020 Leave a comment

Questions:

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

alt text

Is there any advantage to using AND and OR other than clarity?

How to&Answers:

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

Answer:

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