Doc #72675 [Opn->Csd]: Null coalesce operator example has if/else wrong way round
| From: | cmb@php.net | Date: | Tue, 26 Jul 2016 10:25:21 +0000 |
| Subject: | Doc #72675 [Opn->Csd]: Null coalesce operator example has if/else wrong way round | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-13754@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=72675&edit=1
ID: 72675
Updated by: cmb@php.net
Reported by: jonny at jonnybarnes dot uk
Summary: Null coalesce operator example has if/else wrong way
round
-Status: Open
+Status: Closed
Type: Documentation Problem
Package: Documentation problem
PHP Version: 7.0.9
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation better.
Previous Comments:
------------------------------------------------------------------------
[2016-07-26 10:24:54] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&revision=339720
Log: Fix #72675: Null coalesce operator example has if/else wrong way round
------------------------------------------------------------------------
[2016-07-26 10:04:25] jonny at jonnybarnes dot uk
Description:
------------
The Null coalesce operator has an incorrect example. See https://php.net/manual/en/language.operators.comparison.php#language.operators.comparison.coalesce
<?php
// Example usage for: Null Coalesce Operator
$action = $_POST['action'] ?? 'default';
// The above is identical to this if/else statement
if (isset($_POST['action'])) {
$action = 'default';
} else {
$action = $_POST['action'];
}
?>
Should actually be:
<?php
// Example usage for: Null Coalesce Operator
$action = $_POST['action'] ?? 'default';
// The above is identical to this if/else statement
if (isset($_POST['action'])) {
$action = $_POST['action'];
} else {
$action = 'default';
}
?>
See this 3v4l for confirmation: https://3v4l.org/H3V7m
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=72675&edit=1