Best way to give a variable a default value (simulate Perl ||, ||= )
PHP 5.3 has a shorthand ?: operator: $foo = $bar ?: $baz; Which assigns $bar if it’s not an empty value (I don’t know how this would be different in PHP from Perl), otherwise $baz, and is the same as this in Perl and older versions of PHP: $foo = $bar ? $bar : $baz; … Read more