# Equal Null Coalescing Operator

- Thread: https://externals.io/message/91545
- Original archive: https://news-web.php.net/php.internals/91545
- Started by Midori Kocak on 2016-03-08T15:07:02+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #91545 — Midori Kocak — 2016-03-08T15:07:02+00:00

URL: https://externals.io/message/91545#91545

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/
