note 69660 deleted from language.oop5.object-comparison by felipe

From: Date: Sat, 15 Dec 2007 02:07:10 +0000
Subject: note 69660 deleted from language.oop5.object-comparison by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-133522@lists.php.net to get a copy of this message
Note Submitter: donny at semeleer dot nl ---- 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.

« previous php.notes (#133522) next »