You are here: Re: Is it worth it to return a resource by reference? « PHP Programming Language « IT news, forums, messages
Re: Is it worth it to return a resource by reference?

Posted by Jerry Stuckle on 12/16/68 11:59

Ney André de Mello Zunino wrote:
> Jerry Stuckle wrote:
>
>> Passing by reference should never increase the amount of overhead (at
>> least not by any measurable amount), even for an integer. And for
>> more complex objects it will decrease the overhead.
>
>
> Thanks for your reply. Given that the use of references can never hurt
> and that this is my first time using them, could you tell me if I am
> doing it right (according to the sample code in my original post)?
>
> Thank you,
>

Yep. That's how you return a reference. The only comment which is
actually only a matter of style is the generally used syntax is:

function &getPosts(...)

That is, the '&' goes just before the function name instead of
immediately after the 'function' keyword. However, it's a matter of
style, and either should work.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

 

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

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