vrana Tue Jun 21 20:07:30 2005 EDT
Modified files:
/phpdoc/en/language operators.xml
Log:
Comparison with Different Types
http://cvs.php.net/diff.php/phpdoc/en/language/operators.xml?r1=1.87&r2=1.88&ty=u
Index: phpdoc/en/language/operators.xml
diff -u phpdoc/en/language/operators.xml:1.87
phpdoc/en/language/operators.xml:1.88
--- phpdoc/en/language/operators.xml:1.87 Sun Jun 19 10:55:20 2005
+++ phpdoc/en/language/operators.xml Tue Jun 21 20:07:28 2005
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.87 $ -->
+<!-- $Revision: 1.88 $ -->
<chapter id="language.operators">
<title>Operators</title>
<simpara>
@@ -549,6 +549,56 @@
</informalexample>
</para>
+ <table>
+ <title>Comparison with Different Types</title>
+ <tgroup cols="3">
+ <thead>
+ <row>
+ <entry>Type of Operand 1</entry>
+ <entry>Type of Operand 2</entry>
+ <entry>Result</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><type>null</type> or <type>string</type></entry>
+ <entry><type>string</type></entry>
+ <entry>Convert &null; to "", numerical or lexical comparison</entry>
+ </row>
+ <row>
+ <entry><type>bool</type> or <type>null</type></entry>
+ <entry>anything</entry>
+ <entry>Convert to <type>bool</type>, &false; < &true;</entry>
+ </row>
+ <row>
+ <entry><type>object</type></entry>
+ <entry><type>object</type></entry>
+ <entry>Built-in classes can define its own comparison, different
classes are uncomparable, same class - compare properties the same way as
arrays</entry>
+ </row>
+ <row>
+ <entry><type>string</type>, <type>resource</type> or
<type>number</type></entry>
+ <entry><type>string</type>, <type>resource</type> or
<type>number</type></entry>
+ <entry>Translate strings and resources to numbers, usual math</entry>
+ </row>
+ <row>
+ <entry><type>array</type></entry>
+ <entry><type>array</type></entry>
+ <entry>count(op1) < count(op2) => op1 < op2, key from op1 not
found in op2 => uncomparable, otherwise - compare value by value</entry>
+ </row>
+ <row>
+ <entry><type>array</type></entry>
+ <entry>anything</entry>
+ <entry><type>array</type> is greater</entry>
+ </row>
+ <row>
+ <entry><type>object</type></entry>
+ <entry>anything</entry>
+ <entry><type>object</type> is greater</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
<para>
See also <function>strcasecmp</function>,
<function>strcmp</function>,