svn: /phpdoc/en/trunk/language/ operators.xml
| From: | Richard Quadling | Date: | Wed, 13 Jan 2010 16:12:39 +0000 |
| Subject: | svn: /phpdoc/en/trunk/language/ operators.xml | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-5844@lists.php.net to get a copy of this message | ||
rquadling Wed, 13 Jan 2010 16:12:39 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=293507
Log:
Better fix for #50738
Bug: http://bugs.php.net/50738 (Closed) Unclear
documentation in numerical string comparison
Changed paths:
U phpdoc/en/trunk/language/operators.xml
Modified: phpdoc/en/trunk/language/operators.xml
===================================================================
--- phpdoc/en/trunk/language/operators.xml 2010-01-13 14:37:21 UTC (rev 293506)
+++ phpdoc/en/trunk/language/operators.xml 2010-01-13 16:12:39 UTC (rev 293507)
@@ -1096,19 +1096,21 @@
</tgroup>
</table>
<para>
- If you compare an integer with a string, excluding the identical (===) and
- not identical (!==) operators, the string is
- <link linkend="language.types.string.conversion">converted to a
number</link>.
- If you compare two numerical strings, they are compared as integers. These
- rules also apply to the
- <link linkend="control-structures.switch">switch</link> statement.
+ If you compare a number with a string or the comparison involves numerical
+ strings,then each string is
+ <link linkend="language.types.string.conversion">converted to a
number</link>
+ and the comparison performed numerically. These rules also apply to the
+ <link linkend="control-structures.switch">switch</link> statement. The
+ type conversion does not take place when the comparison is === or !== as
+ this involves comparing the type as well as the value.
<informalexample>
<programlisting role="php">
<![CDATA[
<?php
var_dump(0 == "a"); // 0 == 0 -> true
var_dump("1" == "01"); // 1 == 1 -> true
-var_dump("1" == "1e0"); // 1 == 1 -> true
+var_dump("10" == "1e1"); // 10 == 10 -> true
+var_dump(100 == "1e2"); // 100 == 100 -> true
switch ("a") {
case 0: