#33626 [Opn]: Object comparison diverges from PHP 4 to 5

From: Date: Sun, 10 Jul 2005 04:32:14 +0000
Subject: #33626 [Opn]: Object comparison diverges from PHP 4 to 5
References: 1  Groups: php.doc 
Request: Send a blank email to phpdoc+get-969369020@lists.php.net to get a copy of this message
ID: 33626 User updated by: andrebacci dot listas at gmail dot com Reported By: andrebacci dot listas at gmail dot com Status: Open -Bug Type: Class/Object related +Bug Type: Documentation problem PHP Version: 5.0.4 New Comment: http://news.php.net/php.internals/17211 Previous Comments: ------------------------------------------------------------------------ [2005-07-10 01:15:12] andrebacci dot listas at gmail dot com Description: ------------ Object comparison differs from PHP 4 to 5. From docs http://www.php.net/manual/en/language.operators.comparison.php: Table 15-5. Comparison with Different Types object object Built-in classes can define its own comparison, different classes are uncomparable, same class - compare properties the same way as arrays. In my machine works as in docs: andre@macrossv:~/temp$ php -v PHP 4.3.10-10ubuntu4 (cli) (built: Apr 1 2005 14:16:27) Copyright (c) 1997-2004 The PHP Group Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies In pythonic friend's machine, no: ~> php -v PHP 5.0.4 (cli) (built: Jul 7 2005 20:27:16) Copyright (c) 1997-2004 The PHP Group Zend Engine v2.0.4-dev, Copyright (c) 1998-2004 Zend Technologies Reproduce code: --------------- <?php class Foo { var $bar = 1; } $a = new Foo; $b = new Foo; //var_dump($a); //var_dump($b); echo $a == $b ? "True\n" : "False\n"; echo $a === $b ? "True\n" : "False\n"; ?> Expected result: ---------------- True True Actual result: -------------- True False ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=33626&edit=1

« previous php.doc (#969369020) next »