Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #2880

Re: ArrayObject - copy or reference

From Jerry Stuckle <jstucklex@attglobal.net>
Newsgroups comp.lang.php
Subject Re: ArrayObject - copy or reference
Date 2011-08-18 13:54 -0400
Organization A noiseless patient Spider
Message-ID <j2jjla$6hf$1@dont-email.me> (permalink)
References <j1p6c2$nk2$1@news.albasani.net> <4e4ae91c$0$6579$9b4e6d93@newsspool3.arcor-online.net> <j2iu7p$9hs$1@news.albasani.net>

Show all headers | View raw


On 8/18/2011 7:48 AM, Thomas Mlynarczyk wrote:
> Jo Schulze schrieb:
>
>>> $array = array( 1, 2, 3 );
>>> $obj = new ArrayObject( $array );
>>> $obj[0] = 42;
>>> echo $array[0];
>>>
>>> With PHP 5.2.0 this prints 42, with PHP 5.2.4 however, I get 1
>
>> With PHP5.3.7rc this prints 42 which I would expect.
>
> No it doesn't. I just installed PHP 5.3.7RC5 to test it. It prints 1.
>
>> The line
>> $obj[0] = 42;
>> overwites the value with hash key 0
>
> It overwrites the value with hash key 0 in *$obj*. But it should not
> modify *$array*.
>
>> I see no bug here.
>
> There has definitely been a change in behaviour somewhere between 5.2.0
> and 5.2.4. And that should be documented somewhere.
>
> Greetings,
> Thomas
>

Thomas,

I get 1 here also (php 5.2.4).  I would consider this a bug - you might 
want to post it to bugs.php.net.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

ArrayObject - copy or reference Thomas Mlynarczyk <thomas@mlynarczyk-webdesign.de> - 2011-08-08 19:28 +0200
  Re: ArrayObject - copy or reference Jo Schulze <antispam@feuersee.de> - 2011-08-17 00:03 +0200
    Re: ArrayObject - copy or reference Thomas Mlynarczyk <thomas@mlynarczyk-webdesign.de> - 2011-08-18 13:48 +0200
      Re: ArrayObject - copy or reference Jerry Stuckle <jstucklex@attglobal.net> - 2011-08-18 13:54 -0400
        Re: ArrayObject - copy or reference Thomas Mlynarczyk <thomas@mlynarczyk-webdesign.de> - 2011-08-18 20:44 +0200
          Re: ArrayObject - copy or reference Jerry Stuckle <jstucklex@attglobal.net> - 2011-08-18 19:26 -0400

csiph-web