You are here: Re: Arrays always use references? « PHP Programming Language « IT news, forums, messages
Re: Arrays always use references?

Posted by lister on 04/12/07 20:51

On Apr 12, 6:53 pm, "Alvaro G. Vicario"
<webmas...@NOSPAMdemogracia.com> wrote:
> *** lister escribió/wrote (12 Apr 2007 07:53:54 -0700):
>
>
>
>
>
> > $Foo = new CFoo();
> > $Foo->Bar = 5;
>
> > $_SESSION['foo'] = $Foo;
> > $_SESSION['bar'] = $Foo->Bar;
>
> > $Foo->Bar = 10;
>
> > echo $Foo->Bar;
> > echo $_SESSION['foo']->Bar;
> > echo $_SESSION['bar'];
>
> > outputs
> > 10
> > 10
> > 10
>
> In my system, this code prints:
>
> 10
> 10
> 5
>
> A wild guess... register_globals set to on?
>
> --
> -+http://alvaro.es- Álvaro G. Vicario - Burgos, Spain
> ++ Mi sitio sobre programación web:http://bits.demogracia.com
> +- Mi web de humor con rayos UVA:http://www.demogracia.com
> --- Hide quoted text -
>
> - Show quoted text -

Many thanks for your reply, but I think I've just realised what is
going on.
Bar is actually another object in my real code, and I've just read
that all objects are references. D'oh.
I have also found the "clone" command. <slinks away>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация