📜  php代码示例中的空合并运算符示例

📅  最后修改于: 2022-03-11 14:53:51.239000             🧑  作者: Mango

代码示例1
$name = $_GET['name'] ?? $_POST['name'] ?? 'nobody';
//it is equavelent to below conditions

if (isset($_GET['name'])) {
 $name = $_GET['name'];
} elseif (isset($_POST['name'])) {
 $name = $_POST['name'];
} else {
 $name = 'nobody';
}