I've dug around a bit, but I can't seem to find a simple answer as to why you can't code something like
<?php
$x=2;
if(1<$x<3) {
echo "Win!";
} else {
echo "Lose!";
}
?>
My gut says that because PHP reads left-right, it evaluates the first half of the statement (1<$x
) and then just sees <3 which is meaningless. I'd just like someone to confirm (or refute) that this is the case and that any time you're providing conditions in PHP you have to separate out each one. I don't know if this would be called logic or syntax or something else, but you can write expressions like these in other contexts (like SAS) and have them evaluated, so I'd just like to understand why you can't in PHP. Thanks!