This code works:
$foo = getFoo();
if (!$foo) $foo = getBar();
if (!$foo) $foo = getJiggy();
if (!$foo) $foo = getWithIt();
I thought I'd seen somewhere a simplification of it with logical operators:
$foo = (getFoo() || getBar() || getJiggy() || ...);
I figured that the first true statement would get passed, but instead, it's just setting $foo to boolean true
instead of the return value of getFoo()
, getBar()
, etc.
Is there a simplification like what I'm thinking of?