note 104831 deleted from language.operators.comparison by thiago

From: Date: Sun, 10 Jul 2011 06:34:09 +0000
Subject: note 104831 deleted from language.operators.comparison by thiago
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-181393@lists.php.net to get a copy of this message
Note Submitter: Cuong Huy To ---- Please be explicit in the table "Comparison with Various Types". There should be one table for each of the comparison operators (9 operators ===, ==, !=, !==, <>, <, >, <=, >=), otherwise a lot of confusions would occur. Examples of how to build such table are the specifications for functions and operator of ECMA script 262: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf Followings are some of the confusions given the unclear information in current table (PHP 5.3.3) 1) Array or Object is greater ? In the following example, the sentence "Array is always greater" in the table is wrong. <?php class C { } $x = array(); $y = new C(); if ($x > $y) {echo 'array is greater than object';} // Nothing printed. if ($y > $x) {echo 'object is greater than array';} // This is printed. ?> 2) Confusing string comparison in the following example, two numeric strings cannot be compared using the trivial "<" or ">" operator !!! <?php $a = "1234"; $b = "01234"; if ($a == $b) {echo 'equal';} // "equal" if ($a === $b) {echo 'identical';} // nothing printed if ($a < $b) {echo 'equal';} // nothing printed, as they are "equal" if ($a > $b) {echo 'equal';} // nothing printed, as they are "equal" ?>

« previous php.notes (#181393) next »