How about using a couple of nested ternary operators?
For me it's the easiest way to deal with your problem. And since you can use nested ternary operators you should be able to add more checks if needed.
$var = isset($var) ? $var : ($i=check1()) ? $i : ($i=check2()) ? $i : "default" ;
It's almost the same amount of code and it should work.. unless I've misunderstood you. If that's the case I'm sorry.
In comparison with the original code you posted as example, the length is almost the same:
$result = null; $result ||= check1(); $result ||= check2(); $result ||= "default";
- vs -
$var = isset($var) ? $var : ($i=check1()) ? $i : ($i=check2()) ? $i : "default" ;
Nested ternary operators can be a little bit confusing, so here you have it with comments:
// Is $var set?
$var = isset($var) ?
// TRUE: It is, use $var
$var :
// FALSE: $var is not set, run check1
( $i=check1() ) ?
// TRUE: the function check1 returned valid data
$i :
// FALSE: the function check1 returned null or false, run check2
($i=check2()) ?
// TRUE: the function check2 returned valid data
$i :
// FALSE: the function check1 returned null or false, set default value
"default" ;