You are here: Re: Reference to reference? « PHP Programming Language « IT news, forums, messages
Re: Reference to reference?

Posted by Curtis on 02/03/07 13:40

On Thu, 01 Feb 2007 05:49:31 -0800, Tamagafk <tamagafk@gmail.com> wrote:=


> Today I discovered that I don't understand how references work in php.=

> I create object, then I store reference to this object into array.
> Then I do so into another array. And suddenly I have two vars taken by=

> reference which should point to single object, but they are different.=

>
> Is there possibility of "reference to reference" in php?
> I'm just going crazy, can't figure out everything...
>

Why don't you post your code? Unfortunately, we didn't see you coding =

first hand, so we can't pinpoint what's wrong. This is an example of wha=
t =

works:

<?php
$o =3D new a('hello, world');
$o2 =3D new a('goodbye, cruel world');

$array['foo'] =3D& $o;
$array['foo2'] =3D& $o2;

echo $array['foo']->getFoo(); // outputs 'hello, world'
$o->setFoo('como estas');
echo $array['foo']->getFoo(); // outputs 'como estas'

$array['foo2']->setFoo("kon'nichi wa");
echo $o2->getFoo(); // outputs "kon'nichi wa"
?>

-- =

Curtis, http://dyersweb.com

 

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

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