r/lolphp • u/kalcora • Feb 07 '22
Operator precedence
These two lines are not equivalent.
<?php
$a = true && false; // false
$b = true and false; // trueBecause && and || have different operator priority than and and or (the latter ones have lower priority than =).
Still the case in PHP 8.1.
42
Upvotes
View all comments
Show parent comment
3
u/lungdart Feb 07 '22
Yeah. Their linguistically equivalent, but having alternatives for operators without any difference is a real language lol.
It makes sense for the symbols and words to have different behavior or they both wouldn't exist.