Bug #66286 [NEW]: Comparing objects - very strange behaviour
| From: | m dot straczkowski at gmail dot com | Date: | Fri, 13 Dec 2013 15:09:25 +0000 |
| Subject: | Bug #66286 [NEW]: Comparing objects - very strange behaviour | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-183316@lists.php.net to get a copy of this message | ||
From: m dot straczkowski at gmail dot com
Operating system: Linux Ubuntu
PHP version: 5.5.7
Package: Class/Object related
Bug Type: Bug
Bug description:Comparing objects - very strange behaviour
Description:
------------
Hello,
There is a problem with object comparing.
I can't see any logical reason for this to happen.
While comparing two different objects (with == operator) PHP returns
true once and after var_dump / print_r (on objects) it returns false.
As PHP Manual said:
"Two object instances are equal if they have the same attributes and
values, and are instances of the same class."
Our example two objects are not equal because their attribute values are
different.
Script which shows this strange behaviour:
http://pastebin.com/nwEbe7sc
I'm using PHP 5.5.7-1+sury.org~saucy+1
Problem occurred on previous versions too
Test script:
---------------
http://pastebin.com/nwEbe7sc
Expected result:
----------------
bool(false)
B Object
(
[errors:protected] => Array
(
)
[value:protected] => ABC
)
B Object
(
[errors:protected] => Array
(
)
[value:protected] => CBA
)
bool(false)
Actual result:
--------------
bool(true)
B Object
(
[errors:protected] => Array
(
)
[value:protected] => ABC
)
B Object
(
[errors:protected] => Array
(
)
[value:protected] => CBA
)
bool(false)
--
Edit bug report at https://bugs.php.net/bug.php?id=66286&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=66286&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=66286&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=66286&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=66286&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=66286&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=66286&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=66286&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=66286&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=66286&r=support
Expected behavior: https://bugs.php.net/fix.php?id=66286&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=66286&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=66286&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=66286&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=66286&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=66286&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=66286&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=66286&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=66286&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=66286&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=66286&r=mysqlcfg