As we know, if we are using javascript or python, we can use the below statement to get a variable, or its default.
// javascript
alert(a || 'default');
# python
print(a or 'default');
While in php, we may have to call the below:
echo $a ? $a : 'default';
And if the $a is a very long statement, the case is even worse:
echo (
we_made_many_calculation_here_and_this_is_the_result() ?
we_made_many_calculation_here_and_this_is_the_result() :
'default'
);
or
var $result = we_made_many_calculation_here_and_this_is_the_result();
echo $result ? $result : 'default';
any of the above, I think it is not neat.
And I'm blind to find any answer, to find a statement or built-in function to simplifies the work. But after trying to search many ways, I can't find the answer.
So please help.