Midori Kocak
| From: | Midori Kocak | Date: | Tue, 08 Mar 2016 12:03:50 +0000 |
| Subject: | Midori Kocak | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-91539@lists.php.net to get a copy of this message | ||
A question about null coalescing operator..
$this->request->data['comments']['user_id'] =
$this->request->data['comments']['user_id'] ?? ‘value’;
I want to check if some var is null and if the same var is null set the same var to ‘value’.
Hence I am repeating the same variable after the equal operator, this does not feels right.
So I feel that we need another operator like “??=“ similar to +=;
$this->request->data['comments']['user_id’] ??= ‘value’. So if the var
is null it’s set to ‘value’ and else stays the same.
Yours,
Midori Kocak
http://www.mynameismidori.com <http://www.mynameismidori.com/>