[PHP-NOTES] note 130635 added to language.operators.comparison

[email protected] ("[email protected]") Tue, 03 Feb 2026 12:21:09 +0000
Newsgroups php.notes
Message-ID <[email protected]>
This might be obvious to some, but it's worth mentioning it explicitly: The null-coalescing operator is a short-circuiting operator, meaning the right part will not be evaluated at all if it is not used.

// expensiveInitialization() will never be called if $b is not null.
$a = $b ?? expensiveInitialization();
----
Server IP: 206.189.2.9
Probable Submitter: 85.195.255.242
----
Manual Page -- https://php.net/manual/en/language.operators.comparison.php
Edit        -- https://main.php.net/note/edit/130635
Del: integrated  -- https://main.php.net/note/delete/130635/integrated
Del: useless     -- https://main.php.net/note/delete/130635/useless
Del: bad code    -- https://main.php.net/note/delete/130635/bad+code
Del: spam        -- https://main.php.net/note/delete/130635/spam
Del: non-english -- https://main.php.net/note/delete/130635/non-english
Del: in docs     -- https://main.php.net/note/delete/130635/in+docs
Del: other reasons-- https://main.php.net/note/delete/130635
Reject      -- https://main.php.net/note/reject/130635
Search      -- https://main.php.net/manage/user-notes.php