Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:9603 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 3706 invoked by uid 1010); 28 Apr 2004 17:25:36 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 3654 invoked from network); 28 Apr 2004 17:25:36 -0000 Received: from unknown (HELO mail.appliedsec.com) (69.17.65.231) by pb1.pair.com with SMTP; 28 Apr 2004 17:25:36 -0000 Received: from appliedsec.com (localhost.applied.sec [127.0.0.1]) by mail.appliedsec.com (Postfix) with ESMTP id 2468A78C1B for ; Wed, 28 Apr 2004 13:10:26 -0400 (EDT) Message-ID: <408FE90F.3070406@appliedsec.com> Date: Wed, 28 Apr 2004 13:25:35 -0400 User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040124 X-Accept-Language: en-us, en MIME-Version: 1.0 To: internals@lists.php.net Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Subject: == object comparison bug? From: hans@appliedsec.com (Hans Lellelid) I'm using PHP5.0.0RC2. I saw that there was a similar question posted, but apparently that issue had already been fixed. ---code---------------------------- class File { public $var; function __construct($val) { $this->var = $val; } } $t1 = new File("test"); $t2 = new File("test"); print_r($t1); print_r($t2); print "\$t1 == \$t2 ?"; if ($t1 == $t2) { print "YES\n"; } else { print "NO\n"; } ---output---------------------------- File Object ( [var] => test ) File Object ( [var] => test ) $t1 == $t2 ? Notice: Object of class File could not be converted to integer in /var/www/apps/ddi/test.php on line 18 Notice: Object of class File could not be converted to integer in /var/www/apps/ddi/test.php on line 18 YES I don't know why anything is being coverted to an _integer_. Is this intended behavior? If so, how do I do a PHP4-style object contents comparison? Using === doesn't produce any notice, but also means something very different of course. Hans