In Ruby you can easily set a default value for a variable
x ||= "default"
The above statement will set the value of x to "default" if x is nil or false
Is there a similar shortcut in PHP or do I have to use the longer form:
$x = (isset($x))? $x : "default";
Are there any easier ways to handle this in PHP?
See Question&Answers more detail:os