note 69660 added to language.oop5.object-comparison

From: Date: Thu, 14 Sep 2006 08:56:35 +0000
Subject: note 69660 added to language.oop5.object-comparison
Groups: php.notes 
Request: Send a blank email to php-notes+get-117149@lists.php.net to get a copy of this message
In a reaction to Jony dos Santos Kostetzer. It does matter if they have different values. You're using the method Flag within the class Flag. This method returns the given parameter or, if no parameter is set, true. The comparison functions compares the 2 outcomes. In your example true and 10. In PHP this would be similar to : <?php if (true == 10) { return true ; } ?> Which would return true. So you could say that the values have the same outcome even though the input is visibly not the same. Another example : <?php /* ... */ $o = new Flag(1); $p = new Flag(10); /* ... */ echo "Two instances of the same class\n"; compareObjects($o, $p); ?> output: Two instances of the same class o1 == o2 : FALSE o1 != o2 : TRUE o1 === o2 : FALSE o1 !== o2 : TRUE as can be expected. ---- Server IP: 83.137.20.120 Probable Submitter: 62.58.41.165 ---- Manual Page -- http://www.php.net/manual/en/language.oop5.object-comparison.php Edit -- https://master.php.net/note/edit/69660 Del: integrated -- https://master.php.net/note/delete/69660/integrated Del: useless -- https://master.php.net/note/delete/69660/useless Del: bad code -- https://master.php.net/note/delete/69660/bad+code Del: spam -- https://master.php.net/note/delete/69660/spam Del: non-english -- https://master.php.net/note/delete/69660/non-english Del: in docs -- https://master.php.net/note/delete/69660/in+docs Del: other reasons-- https://master.php.net/note/delete/69660 Reject -- https://master.php.net/note/reject/69660 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#117149) next »