note 125585 added to language.operators.comparison
| From: | itsaconatitsacondotnet@php.net | Date: | Wed, 09 Dec 2020 09:31:53 +0000 |
| Subject: | note 125585 added to language.operators.comparison | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-215959@lists.php.net to get a copy of this message | ||
Be aware that the null coalesce operator (??) has a lower priority than most other operators, so
parentheses are usually a good idea if the output is used in anything other than an assignment.
<?php
$var = 1;
if ($var ?? 0 == 2) {} // will evaluate to true
if (2 == $undefinedVar ?? 0) {} // will throw an error
if (($var ?? 0) == 2) {} // will evaluate to false
?>
https://www.php.net/manual/en/language.operators.precedence.php
----
Server IP: 45.112.84.4
Probable Submitter: 45.112.85.244 (proxied: 77.172.55.111)
----
Manual Page -- http://php.net/manual/en/language.operators.comparison.php
Edit -- https://master.php.net/note/edit/125585
Del: integrated -- https://master.php.net/note/delete/125585/integrated
Del: useless -- https://master.php.net/note/delete/125585/useless
Del: bad code -- https://master.php.net/note/delete/125585/bad+code
Del: spam -- https://master.php.net/note/delete/125585/spam
Del: non-english -- https://master.php.net/note/delete/125585/non-english
Del: in docs -- https://master.php.net/note/delete/125585/in+docs
Del: other reasons-- https://master.php.net/note/delete/125585
Reject -- https://master.php.net/note/reject/125585
Search -- https://master.php.net/manage/user-notes.php