svn: /phpdoc/en/trunk/appendices/migration70/incompatible/ integers.xml

From: Date: Sat, 12 Sep 2015 19:07:21 +0000
Subject: svn: /phpdoc/en/trunk/appendices/migration70/incompatible/ integers.xml
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-13730@lists.php.net to get a copy of this message
tpunt Sat, 12 Sep 2015 19:07:21 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=337816 Log: Document new division by zero semantics Changed paths: U phpdoc/en/trunk/appendices/migration70/incompatible/integers.xml Modified: phpdoc/en/trunk/appendices/migration70/incompatible/integers.xml =================================================================== --- phpdoc/en/trunk/appendices/migration70/incompatible/integers.xml 2015-09-12 06:00:14 UTC (rev 337815) +++ phpdoc/en/trunk/appendices/migration70/incompatible/integers.xml 2015-09-12 19:07:21 UTC (rev 337816) @@ -56,6 +56,55 @@ such shifts was architecture dependent. </para> </sect3> + + <sect3 xml:id="migration70.incompatible.integers.div-by-zero"> + <title>Changes to Division By Zero</title> + + <para> + Previously, when 0 was used as the divisor for either the divide (/) or + modulus (%) operators, an E_WARNING would be emitted and + <constant>false</constant> would be returned. Now, the divide operator + returns a float as either +INF, -INF, or NAN. The modulus operator E_WARNING + has been removed and will throw a <classname>DivisionByZeroError</classname> + exception. + </para> + <informalexample> + <programlisting role="php"> +<![CDATA[ +<?php +var_dump(3/0); +var_dump(0/0); +var_dump(0%0); +?> +]]> + </programlisting> + &example.outputs.5; + <screen> +<![CDATA[ +Warning: Division by zero in %s on line %d +bool(false) + +Warning: Division by zero in %s on line %d +bool(false) + +Warning: Division by zero in %s on line %d +bool(false) +]]> + </screen> + &example.outputs.7; + <screen> +<![CDATA[ +Warning: Division by zero in %s on line %d +float(INF) + +Warning: Division by zero in %s on line %d +float(NAN) + +PHP Fatal error: Uncaught DivisionByZeroError: Modulo by zero in %s line %d +]]> + </screen> + </informalexample> + </sect3> </sect2> <!-- Keep this comment at the end of the file

« previous php.doc.cvs (#13730) next »