Reply to Re: Passing by reference better than returning a value when calling a function?

Your name:

Reply:


Posted by Rik Wasmus on 10/28/07 19:04

On Sun, 28 Oct 2007 19:25:38 +0100, duzhidian@gmail.com =

<duzhidian@gmail.com> wrote:

> Hello:
>
> When I need a function to generate a string, I have two methods:
>
> 1.
> pass by reference:
>
> mystring =3D "";
> myfunction( mystring ); // prototype of myfunction( &anystring );
>
> OR 2.
> mystring =3D myfunction(); //which return a string
>
> According to experience of C/C++, the former one is better as of the
> efficient, how about PHP?

The PHP engine is usually smarter then you think, so efficiency wise the=
re =

will be very little difference (you can test this offcourse examining ti=
me =

& memory usage). From a logical standpoint though, it makes very little =
=

sense to create a _new_ string in an existing variable by reference. I'd=
=

say functions taking arguments by reference only make sense when they =

either alter data directly related to their 'previous' value, or store t=
he =

values in come other scope.
-- =

Rik Wasmus

[Back to original 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

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