vrana           Fri Aug  6 15:13:20 2004 EDT

  Modified files:              
    /phpdoc/en/language operators.xml 
  Log:
  Comparison of numerical strings (bug #23110)
  
http://cvs.php.net/diff.php/phpdoc/en/language/operators.xml?r1=1.77&r2=1.78&ty=u
Index: phpdoc/en/language/operators.xml
diff -u phpdoc/en/language/operators.xml:1.77 phpdoc/en/language/operators.xml:1.78
--- phpdoc/en/language/operators.xml:1.77       Mon Aug  2 06:54:00 2004
+++ phpdoc/en/language/operators.xml    Fri Aug  6 15:13:20 2004
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.77 $ -->
+<!-- $Revision: 1.78 $ -->
  <chapter id="language.operators">
   <title>Operators</title>
   <simpara>
@@ -461,6 +461,32 @@
      </tbody>
     </tgroup>
    </table>
+   <para>
+    If you compare integer with the string, the string is
+    <link linkend="language.types.string.conversion">converted to number</link>.
+    If you compare two numerical strings, they are compared as integers. These
+    rules are valid also for the
+    <link linkend="control-structures.switch">switch</link> statement.
+    <informalexample>
+     <programlisting role="php">
+<![CDATA[
+<?php
+var_dump(0 == "a"); // 0 == 0 -> true
+var_dump("1" == "01"); // 1 == 1 -> true
+
+switch ("a") {
+case 0:
+    echo "0";
+    break;
+case "a": // never reached because "a" is already matched with 0
+    echo "a";
+    break;
+}
+?>
+]]>
+     </programlisting>
+    </informalexample> 
+   </para>
    <para>
     Another conditional operator is the "?:" (or ternary) operator.
     <informalexample>

Reply via email to