NYCPHP Meetup

NYPHP.org

[nycphp-talk] more on &$var in function

Hans Zaunere hans at nyphp.org
Sat Sep 6 17:32:24 EDT 2003



Michael Southwell wrote:
> Thanks for responses to my question about the need for global $var 
> within a function whose parameter is &$var (unnecessary; function is 
> operating directly on the original because of the &).
> 
> Now this raises another question.  Given the above, in those cases where 
> a function is intended to operate on a global variable--and only those 
> cases, why wouldn't you *always* define the parameter with & instead of 
> using a global statement?

It's a matter of context and style, IMO.  Function arguments are explicit to that function call, while a global variable isn't and is expected to be operated on regardless of a particular function.  And, as Chris and Chris pointed out, you'll get some nasty-long function calls :)

H




More information about the talk mailing list