add tables for assignment operators

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@350379 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Tiffany Taylor 2020-08-25 13:02:40 +00:00
parent 99b3c9956b
commit a14d8cc169

View file

@ -604,6 +604,125 @@ Strict Standards: Assigning the return value of new by reference is deprecated i
section of the manual.
</para>
</sect2>
<sect2 xml:id="language.operators.assignment.arithmetic">
<title>Arithmetic Assignment Operators</title>
<informaltable>
<tgroup cols="3">
<thead>
<row>
<entry>Example</entry>
<entry>Equivalent</entry>
<entry>Operation</entry>
</row>
</thead>
<tbody>
<row>
<entry>$a += $b</entry>
<entry>$a = $a + b</entry>
<entry>Addition</entry>
</row>
<row>
<entry>$a -= $b</entry>
<entry>$a = $a - $b</entry>
<entry>Subtraction</entry>
</row>
<row>
<entry>$a *= $b</entry>
<entry>$a = $a * $b</entry>
<entry>Multiplication</entry>
</row>
<row>
<entry>$a /= $b</entry>
<entry>$a = $a / $b</entry>
<entry>Division</entry>
</row>
<row>
<entry>$a %= $b</entry>
<entry>$a = $a % $b</entry>
<entry>Modulus</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</sect2>
<sect2 xml:id="language.operators.assignment.bitwise">
<title>Bitwise Assignment Operators</title>
<informaltable>
<tgroup cols="3">
<thead>
<row>
<entry>Example</entry>
<entry>Equivalent</entry>
<entry>Operation</entry>
</row>
</thead>
<tbody>
<row>
<entry>$a &amp;= $b</entry>
<entry>$a = $a &amp; $b</entry>
<entry>Bitwise And</entry>
</row>
<row>
<entry>$a |= $b</entry>
<entry>$a = $a | $b</entry>
<entry>Bitwise Or</entry>
</row>
<row>
<entry>$a ^= $b</entry>
<entry>$a = $a ^ $b</entry>
<entry>Bitwise Xor</entry>
</row>
<row>
<entry>$a &lt;&lt;= $b</entry>
<entry>$a = $a &lt;&lt; $b</entry>
<entry>Left Shift</entry>
</row>
<row>
<entry>$a &gt;&gt;= $b</entry>
<entry>$a = $a &gt;&gt; $b</entry>
<entry>Right Shift</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</sect2>
<sect2 xml:id="language.operators.assignment.other">
<title>Other Assignment Operators</title>
<informaltable>
<tgroup cols="3">
<thead>
<row>
<entry>Example</entry>
<entry>Equivalent</entry>
<entry>Operation</entry>
</row>
</thead>
<tbody>
<row>
<entry>$a .= $b</entry>
<entry>$a = $a . $b</entry>
<entry>String Concatenation</entry>
</row>
<row>
<entry>$a ??= $b</entry>
<entry>$a = $a ?? $b</entry>
<entry>Null Coalesce</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</sect2>
<sect2 xml:id="language.operators.assignment.see-also">
<para>
See also the manual sections on <link linkend="language.operators.arithmetic">
arithmetic operators</link>, <link linkend="language.operators.bitwise">bitwise operators</link>,
<link linkend="language.operators.string">string operators</link>, and
<link linkend="language.operators.comparison.coalesce">null coalescing operator</link>.
</para>
</sect2>
</sect1>
<sect1 xml:id="language.operators.bitwise">
@ -2401,8 +2520,7 @@ bool(false)
</para>
<para>
instanceof does not throw any error if the variable being tested is not
an object, it simply returns &false;. Constants, however, were not allowed
prior to PHP 7.3.0.
an object, it simply returns &false;. Constants, however, are not allowed.
<example>
<title>Using <literal>instanceof</literal> to test other variables</title>
<programlisting role="php">
@ -2425,26 +2543,6 @@ bool(false)
bool(false)
bool(false)
PHP Fatal error: instanceof expects an object instance, constant given
]]>
</screen>
</example>
</para>
<para>
As of PHP 7.3.0, constants are allowed on the left-hand-side of the
<literal>instanceof</literal> operator.
<example>
<title>Using <literal>instanceof</literal> to test constants</title>
<programlisting role="php">
<![CDATA[
<?php
var_dump(FALSE instanceof stdClass);
?>
]]>
</programlisting>
&example.outputs.73;
<screen>
<![CDATA[
bool(false)
]]>
</screen>
</example>