Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:9767 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 59930 invoked by uid 1010); 9 May 2004 16:17:43 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 59861 invoked from network); 9 May 2004 16:17:41 -0000 Received: from unknown (HELO mail.zend.com) (192.117.235.230) by pb1.pair.com with SMTP; 9 May 2004 16:17:41 -0000 Received: (qmail 12581 invoked from network); 9 May 2004 16:17:36 -0000 Received: from localhost (HELO AndiNotebook.zend.com) (127.0.0.1) by localhost with SMTP; 9 May 2004 16:17:36 -0000 Message-ID: <5.1.0.14.2.20040509191720.035c6eb8@127.0.0.1> X-Sender: andi@127.0.0.1 X-Mailer: QUALCOMM Windows Eudora Version 5.1 Date: Sun, 09 May 2004 19:17:35 +0300 To: Rui Hirokawa ,internals@lists.php.net In-Reply-To: <20040509162726.5B3C.RUI_HIROKAWA@ybb.ne.jp> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed Subject: Re: [PHP-DEV] Comparing objects on PHP5 From: andi@zend.com (Andi Gutmans) References: <20040509162726.5B3C.RUI_HIROKAWA@ybb.ne.jp> Did you check HEAD? I fixed something to do with the comparison. if it still doesn't work please let me know. Andi At 04:43 PM 5/9/2004 +0900, Rui Hirokawa wrote: >Hi, > >I think objects comparison in PHP5 has problems. >Here is small sample code, > >class Foo { > var $v = 1; > } > class Boo { > var $v = 1; > } > $a = new Foo; > $b = new Foo; > $c = new Boo; > $d = new Foo; > $d->v = 2; > $e = $a; > >// value comparison > echo $a == $b ? "same," : "not same,"; > echo $a == $c ? "same," : "not same,"; > echo $a == $d ? "same," : "not same,"; > echo $a == $e ? "same" : "not same"; > echo "\n"; >// value and type comparison > echo $a === $b ? "same," : "not same,"; > echo $a === $c ? "same," : "not same,"; > echo $a === $d ? "same," : "not same,"; > echo $a === $e ? "same" : "not same"; >?> > >The output from PHP4 and PHP5(ze1_compat on/off) is, > >PHP 4.3.6 : > same,not same,not same,same > same,not same,not same,same > >PHP 5.0.0RC2 zend.ze1_compatibility_mode=off : > same,not same,not same,same > (Notice: Object of class [Foo|Boo] could not be converted to integer) > not same,not same,not same,same > >PHP 5.0.0RC2 zend.ze1_compatibility_mode=on : > same,same,not same,same > not same,not same,not same,not same > > >The problem and question are, >1. the different class is recognised as same in PHP5 (ze1_compat=on). >2. the same object is recognised as different in PHP5 (ze1_compat=on). >3. Why integer casting of object was implicitly applied in PHP5 > (ze1_compat=off) ? > >-- >Rui Hirokawa > >-- >PHP Internals - PHP Runtime Development Mailing List >To unsubscribe, visit: http://www.php.net/unsub.php