Categories
BEST PHP CODE

PHP 7.4 – Null Coalescing Assignment Operator

Null Coalescing Assignment Operator

In the long run, this code could be a bit difficult to maintain. So, aiming to help developers to write more intuitive code, this RFC proposes the introduction of the null coalescing assignment operator (??=). So, instead of writing the previous code, we could write the following:

$this->request->data['comments']['user_id'] ??= ‘value’;

Leave a Reply