-4

PHP 7 で null Coalesce 演算子 (?? 演算子) が登場する可能性に興奮していますが、すべてのケースを理解しているわけではありません。

次の場合、結果はどうなりますか?

function NC($x){
    $y = array();
    $y['test'] = $x;
    $returnThis = $y['test'] ?? "Foo";
    return $returnThis;
}

echo(NC(NULL)); // I know this will return "Foo".
/* But I have no clue about what these will return. */
echo(NC(0));
echo(NC(-1));
echo(NC(""));
echo(NC(array()));
4

1 に答える 1