I have the following Code in PHP
if($row["phone"])
$phone = $row["phone"];
else
$phone = $row["mobile"];
In JavaScript I could simply write
phone = row.phone || row.mobile;
which is much easier to write, and looks much better. If I try the same in PHP it would simply return true
$phone = $row["phone"] || $row["mobile"];
echo $phone; // 1
Is there any operator in PHP that offers me the same functionality as the in JavaScript?
I tried the bitwise or |
, but that only works sometimes and sometimes i get really weird results.