Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:10088 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 99864 invoked by uid 1010); 25 May 2004 13:13:01 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 99797 invoked from network); 25 May 2004 13:13:00 -0000 Received: from unknown (HELO mail.zend.com) (192.117.235.230) by pb1.pair.com with SMTP; 25 May 2004 13:13:00 -0000 Received: (qmail 24387 invoked from network); 25 May 2004 13:12:57 -0000 Received: from int.zend.com (HELO AndiNotebook.zend.com) (10.1.1.1) by int.zend.com with SMTP; 25 May 2004 13:12:57 -0000 Message-ID: <5.1.0.14.2.20040525161238.061c8f78@127.0.0.1> X-Sender: andi@127.0.0.1 X-Mailer: QUALCOMM Windows Eudora Version 5.1 Date: Tue, 25 May 2004 16:12:56 +0300 To: "Aidan Lister" ,internals@lists.php.net In-Reply-To: <20040525130908.85118.qmail@pb1.pair.com> References: <20040522064028.3397.qmail@pb1.pair.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed Subject: Re: [PHP-DEV] Re: Internal casting of objects as array keys From: andi@zend.com (Andi Gutmans) This code doesn't seem to have changed. Can you send me a 3-4 liner which errors out in PHP 4 and not in PHP 4? Thanks, Andi At 11:03 PM 5/25/2004 +1000, Aidan Lister wrote: >I'm going to go ahead and post this as a bug, unless there is a reason noone >replied... > >"Aidan Lister" wrote in message >news:20040522064028.3397.qmail@pb1.pair.com... > > Hello devs, > > > > I'd like to discuss the use of objects as array keys. > > > > > class idobject { > > private $_id; > > function __construct ($id) { $this->_id = $id; } > > function __tostring () { return (int)$this->_id; } > > } > > > > $blah1 = new idobject(1); > > $blah2 = new idobject(2); > > $blah3 = new idobject(3); > > $blah4 = new idobject(4); > > > > $array = array ( > > $blah1 => 'blah1', > > $blah2 => 'blah2', > > $blah3 => 'blah3', > > $blah4 => 'blah4', > > ); > > > > echo "
";
> > var_dump($array);
> > echo "
"; > > ?> > > > > In PHP4 this results in an error, > > In PHP5 there is no error, the array is simply empty. > > > > An array key can only be a string/int, thus, when someone attempts to use >an > > array as a key would it not make sense to cast the object? > > > > This behaviour would then be consistant with resources. > > > > Regards, > > Aidan > >-- >PHP Internals - PHP Runtime Development Mailing List >To unsubscribe, visit: http://www.php.net/unsub.php