The difference is in what the operators return. In PHP, the logical operators return boolean values. In JavaScript, the logical operators return the actual operands and rely on implicit conversions to turn them into booleans when the context requires it.
If you want the functionality of returning the first operand if it evaluates to TRUE and the last otherwise in PHP, you can use the short-hand form of the ternary operator (?:
):
PHP.net says:
Since PHP 5.3, it is possible to leave out the middle part of the ternary operator. Expression expr1 ?: expr3 returns expr1 if expr1 evaluates to TRUE, and expr3 otherwise.