note 126306 deleted from migration70.new-features by cmb
| From: | cmb@php.net | Date: | Wed, 04 Aug 2021 10:42:34 +0000 |
| Subject: | note 126306 deleted from migration70.new-features by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-216742@lists.php.net to get a copy of this message | ||
Note Submitter: cory ' at at ' bitslip6 dot com
----
peculiar behavior on null coalescing operator in an if statement
$x = array();
if ($x['b']??'n/a' === 'whatever') { // this is always true if
'b' does not exist
if (($x['b']??'n/a') === 'whatever') { // only true if
$x['b'] === 'whatever'
you probably want to wrap your null coalescing in parentheses for most cases. * same result with ==
and ===