You are here: Re: Any difference between these two? « PHP Programming Language « IT news, forums, messages
Re: Any difference between these two?

Posted by ZeldorBlat on 12/08/05 01:25

Chung Leong wrote:
> ZeldorBlat wrote:
> > Chung Leong wrote:
> > > Is there anything funcationally difference between the following
> > > snippets:
> > >
> > > // first
> > > $lines[] = array();
> > > $line =& $lines[count($lines) - 1];
> > >
> > > // second
> > > $line = array();
> > > $lines[] =& $line;
> > >
> > > They should do the thing. A voice in my head though is saying there's a
> > > subtle difference.
> >
> > They look the same to me -- at the end of the day both $line and
> > $lines[0] point to the same, empty array. Of course #2 is more
> > readable and straightforward.
>
> I think you're right. My concern was that in the first block, an array
> was added to $lines, while in the second, a reference was added.
> Momentarily I forgot that references don't exist as discrete objects.
>
> Thanks.

Yeah -- I like PHP's reference model a lot, mainly for it's simplicity:
every single "variable" is just a "label" for some value in memory.
Creating a "reference" is really just a way of creating another label
for that same value in that same spot in memory. Of course there are
some rules about what is always assigned by reference and what is
always copied.

 

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

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