Just a quick note about how PHP conditional operators differs from ECMA (JS and AS)…

The double-pipe ‘OR’ operator, in JS, evaluated to the value of the expression that is not false. In PHP, it evaluates to true if any any expression is true, or false if not (the output will actually be “1” if true, or “0” if false – which is how PHP treats any boolean evaluation).

In PHP 5.3 and later, you can use a modified ternary expression to simulate the JS logic – just leave out the middle component…