PHP Alternative Assignment

In JavaScript you can use the following syntax:

var foo = this.bar || 'default';

In PHP 5.3 the equivalent syntax would be a imaginative use of the ternary operator.

$foo = $bar ?: 'default';

If you want to use the logical or operator, || you would have to take a roundabout.

$foo || $foo = 'default';