What is null coalescing assignment ??= operator in PHP 7.4

后端 未结 5 1631
渐次进展
渐次进展 2020-12-06 16:51

I\'ve just seen a video about upcoming PHP 7.4 features and saw this new ??= operator. I already know the ?? operator.

How\'s this different

5条回答
  •  天命终不由人
    2020-12-06 17:05

    Example Docs:

    $array['key'] ??= computeDefault();
    // is roughly equivalent to
    if (!isset($array['key'])) {
        $array['key'] = computeDefault();
    }
    

提交回复
热议问题