Doc #79673 [Com]: "roughly equivalent to" without explaining the difference
| From: | a at b dot c dot de | Date: | Wed, 17 Jun 2020 21:54:33 +0000 |
| Subject: | Doc #79673 [Com]: "roughly equivalent to" without explaining the difference | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-17655@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79673&edit=1
ID: 79673
Comment by: a at b dot c dot de
Reported by: kasperheij at hotmail dot com
Summary: "roughly equivalent to" without explaining the
difference
Status: Open
Type: Documentation Problem
Package: Documentation problem
PHP Version: 7.4.6
Block user comment: N
Private report: N
New Comment:
The "??=" operator isn't mentioned at all in the reference part of the documentation
(under neither "comparison operators", where the base '??' is given; nor
"assignment operators", which description of "combined operators" hasn't
been updated). One of those would be the place to describe its behaviour and how it's different
from the more long-winded form.
Previous Comments:
------------------------------------------------------------------------
[2020-06-10 18:18:27] alexinbeijing at gmail dot com
Interesting question!
I can't find any difference in the actual behavior, although the bytecodes executed by the
interpreter are different in either case, so it is possible that there might be some (very small)
difference in performance.
See:
https://3v4l.org/Z3dPV/vld#output
https://3v4l.org/2W7W1/vld#output
------------------------------------------------------------------------
[2020-06-04 11:21:51] kasperheij at hotmail dot com
Description:
------------
---
From manual page: https://php.net/migration74.new-features
---
```
<?php
$array['key'] ??= computeDefault();
// is roughly equivalent to
if (!isset($array['key'])) {
$array['key'] = computeDefault();
}
?>
```
"// is roughly equivalent to" says that there _is_ a difference without specifying this
delta.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79673&edit=1