php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #33626 Object comparison diverges from PHP 4 to 5
Submitted: 2005-07-10 01:15 UTC Modified: 2005-07-14 12:04 UTC
From: andrebacci dot listas at gmail dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: 5.0.4 OS:
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: andrebacci dot listas at gmail dot com
New email:
PHP Version: OS:

 

 [2005-07-10 01:15 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-07-10 06:32 UTC] andrebacci dot listas at gmail dot com
http://news.php.net/php.internals/17211
 [2005-07-10 16:00 UTC] andrebacci dot listas at gmail dot com
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.
 [2005-07-14 12:04 UTC] vrana@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

Link to PHP 5 object comparison to table 15-4.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu May 01 19:01:30 2025 UTC