on-internet
← Community

PHP: Null coalescing operator

Stack Overflow ·

I am trying to understand how the null coalescing operator really does work. So, I tested many examples after reading the documentation in php.net and some posts on Stack Overflow. However, I can't understand this code: <?php $x = false ?? 'stackoverflow'; var_dump($x); // bool(false) since it's equivalent to (from Null coalescing operator) isset(false) ? false : 'stackoverflow'; and since isset(false) generates a fatal error. What is the explanation?

Comments

Sign in or sign up to comment and upvote.

No comments yet.