Welcome Guest, Not a member yet? Register   Sign In
<?=$item ?> or <?php echo $item;?> witch is faster ?
#18

[eluser]Daniel Moore[/eluser]
The only difference between AND and && is operator precedence. It will evaluate the same, but not necessarily in the same order when evaluating a larger expression. && has a higher precedence than AND.

Since I always use parentheses to make order of evaluation clear (which also improves readability), it is not an issue for me. I always stick to OR and AND both, simply because they are faster to type (for me, being a touch typist.)

&& has a higher precedence, followed by ||, then followed by the ternary operator, then followed by the assignment operators, then followed by AND then OR. So the real question is, do you need your AND or && evaluated before or after an assignment operator or ternary operator is evaluated? To me, it is simply too much to keep up with remembering OR is evaluated after ternary and assignments and && before, which can lead to mistakes in coding. In my book, if you're going to use &&, then use ||, and if you're going to use OR, then use AND. It's makes for more consistent and easier to read code overall. This is one area I disagree strongly with the code style guideline for CodeIgniter. I prefer to use logical readability for my guideline as how to code.


Messages In This Thread
<?=$item ?> or <?php echo $item;?> witch is faster ? - by El Forum - 05-09-2011, 07:28 AM



Theme © iAndrew 2016 - Forum software by © MyBB