#33626 [Bgs->Opn]: Object comparison diverges from PHP 4 to 5
| From: | andrebacci dot listas at gmail dot com | Date: | Sun, 10 Jul 2005 14:00:37 +0000 |
| Subject: | #33626 [Bgs->Opn]: Object comparison diverges from PHP 4 to 5 | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969369027@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: Bogus
+Status: Open
Bug Type: Documentation problem
PHP Version: 5.0.4
New Comment:
http://www.php.net/manual/en/language.operators.comparison.php
Table 15-4, table 15-5, example 15-2 and no mention to BC in PHP 4 to
5.
Previous Comments:
------------------------------------------------------------------------
[2005-07-10 09:05:57] tony2001@php.net
http://www.php.net/manual/en/language.oop5.object-comparison.php
------------------------------------------------------------------------
[2005-07-10 06:32:12] andrebacci dot listas at gmail dot com
http://news.php.net/php.internals/17211
------------------------------------------------------------------------
[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