using PHP's null coalescing operator on an array

前端 未结 1 1008
小鲜肉
小鲜肉 2020-12-21 21:02

I am using PHP\'s null coalescing operator described by http://php.net/manual/en/migration70.new-features.php.

Null coalescing operator ¶
The null coalescing         


        
相关标签:
1条回答
  • 2020-12-21 21:48

    You don't add anything to params. Your given code simply generates an unused return value:

    $params['phone'] ?? 'default'; // returns phone number or "default", but is unused
    

    Thus, you will still have to set it:

    $params['phone'] = $params['phone'] ?? 'default';
    
    0 讨论(0)
提交回复
热议问题