note 98725 added to language.oop5.object-comparison

From: Date: Fri, 02 Jul 2010 16:00:26 +0000
Subject: note 98725 added to language.oop5.object-comparison
Groups: php.notes 
Request: Send a blank email to php-notes+get-170663@lists.php.net to get a copy of this message
Comparison using <> operators should be documented. Between two objects, at least in PHP5.3, the comparison operation stops and returns at the first unequal property found. <?php $o1 = new stdClass(); $o1->prop1 = 'c'; $o1->prop2 = 25; $o1->prop3 = 201; $o1->prop4 = 1000; $o2 = new stdClass(); $o2->prop1 = 'c'; $o2->prop2 = 25; $o2->prop3 = 200; $o2->prop4 = 9999; echo (int)($o1 < $o2); // 0 echo (int)($o1 > $o2); // 1 $o1->prop3 = 200; echo (int)($o1 < $o2); // 1 echo (int)($o1 > $o2); // 0 ?> ---- Server IP: 69.147.83.197 Probable Submitter: 70.124.94.109 ---- Manual Page -- http://www.php.net/manual/en/language.oop5.object-comparison.php Edit -- https://master.php.net/note/edit/98725 Del: integrated -- https://master.php.net/note/delete/98725/integrated Del: useless -- https://master.php.net/note/delete/98725/useless Del: bad code -- https://master.php.net/note/delete/98725/bad+code Del: spam -- https://master.php.net/note/delete/98725/spam Del: non-english -- https://master.php.net/note/delete/98725/non-english Del: in docs -- https://master.php.net/note/delete/98725/in+docs Del: other reasons-- https://master.php.net/note/delete/98725 Reject -- https://master.php.net/note/reject/98725 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#170663) next »