Possible Duplicate:
php variable = variable1 || variable2
Trying to do this in PHP evaluates to true, instead of returning ‘nothing’ like js does.
//Javascript
var stuff = false;
document.write(stuff || 'nothing');
So I have to do this. Is there anyway to avoid typing the variable stuff twice?
//PHP
$stuff = false;
echo !empty($stuff)?$stuff:'nothing';
If you use PHP 5.3 or later you can use the shorthand ternary format: