这个运算符怎么样'??' 在PHP代码中工作.?

Adh*_*hom 2 php php-7

$array = ['name'=>'Jonh', 'lastname' => 'Doe', 'nickname' => 'JD'] ;

$person = $array['name'] ?? null ; //try to change  null to true or false<br>
    echo $person;

$person = $array['age'] ?? null;  //no Undefined index: age<br>
    echo $person;
Run Code Online (Sandbox Code Playgroud)

我找不到任何关于它的文档.

vla*_*ras 8

这是新的PHP7"null coalescing operator":

// Fetches the value of $_GET['user'] and returns 'nobody'
// if it does not exist.
$username = $_GET['user'] ?? 'nobody';
// This is equivalent to:
$username = isset($_GET['user']) ? $_GET['user'] : 'nobody';
Run Code Online (Sandbox Code Playgroud)

三元运算符的 缩写形式?:多年来几乎相同(至少PHP 5.3)