In some languages, you can do
$a = $b OR $c OR die(\"no value\");
That is, the OR will short-circuit, only evaluating values from left to right
You could use some kind of coalesce function:
function coalesce() { foreach (func_get_args() as $arg) { if ($arg) { return $arg; } } return null; } $a = coalesce($a, $b) or die("no value");