Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions language/operators/comparison.xml
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ echo 0 ?: 0 ?: 0 ?: 3, PHP_EOL; //3
// Example usage for: Null Coalesce Operator
$action = $_POST['action'] ?? 'default';

// The above is identical to this if/else statement
// The above is equivalent to this if/else statement
if (isset($_POST['action'])) {
$action = $_POST['action'];
} else {
Expand All @@ -473,14 +473,13 @@ if (isset($_POST['action'])) {
</programlisting>
</example>
The expression <literal>(expr1) ?? (expr2)</literal> evaluates to
<replaceable>expr2</replaceable> if <replaceable>expr1</replaceable> is
&null;, and <replaceable>expr1</replaceable> otherwise.
<replaceable>expr1</replaceable> if <replaceable>expr1</replaceable> is set
and not &null;, otherwise <replaceable>expr2</replaceable>.
</para>
<para>
<simpara>
In particular, this operator does not emit a notice or warning if the left-hand side
value does not exist, just like <function>isset</function>. This is especially
useful on array keys.
</para>
value is not set. This is especially useful on array keys.
</simpara>
<note>
<simpara>
Please note that the null coalescing operator is an expression, and that it
Expand Down