You are here: Re: Need to return reference in this case? « PHP Programming Language « IT news, forums, messages
Re: Need to return reference in this case?

Posted by gosha bine on 06/02/07 22:42

howa wrote:
> On Jun 2, 7:51 pm, gosha bine <stereof...@gmail.com> wrote:
>> The second. "foo = new Foo" will create two copies of "Foo" in php4.
>>
>
> what do you mean? you mean the second one is preferred?
>
> why the first one will create two copies of "Foo" but not the first
> one?
>

$foo = new Foo

does the following in php4:

1) a chunk of memory is allocated and object's constructor is called to
initialize this memory
2) another chunk of memory is allocated and everything from the first
chunk is copied to it
3) variable 'foo' is being set to address of this second chunk
4) the first chunk is being disposed.

Apart from being ineffective, this technique will apparently fail if an
object saves reference to itself ($this) in constructor or when you need
exactly one instance.

>
>> Any reason why you can't use php5?
>>
>
> php4 is stable, and its OOP function is enough (and simple) as far as
> known.
>

I agree that OO "features" of php5 are mostly useless and php4 has
everything one needs to write OO programs. However, I still won't
recommend it, exactly for the reason described above.

--
gosha bine

extended php parser ~ http://code.google.com/p/pihipi
blok ~ http://www.tagarga.com/blok

 

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

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