FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » ArrayObject - copy or reference
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: ArrayObject - copy or reference [message #175161 is a reply to message #175150] Thu, 18 August 2011 11:48 Go to previous messageGo to previous message
Thomas Mlynarczyk is currently offline  Thomas Mlynarczyk
Messages: 131
Registered: September 2010
Karma:
Senior Member
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

--
Ce n'est pas parce qu'ils sont nombreux à avoir tort qu'ils ont raison!
(Coluche)
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Freelance PHP Developer
Next Topic: How to integrate paypal payment Indian currency support ..?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Nov 28 19:36:03 GMT 2024

Total time taken to generate the page: 0.04856 seconds