NYCPHP Meetup

NYPHP.org

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

Michael Southwell southwell at dneba.com
Fri Sep 5 14:14:13 EDT 2003


At 11:16 AM 9/5/2003, you wrote:
>Chris Shiflett wrote:
>
>>--- Michael Southwell <southwell at dneba.com> wrote:
>>
>>
>>>why wouldn't you *always* define the parameter with & instead of
>>>using a global statement?
>>>
>>
>>Speaking personally, it depends on whether I think the parameter is closely
>>related to the function and how much data is already required to be 
>>passed in.
>>
>
>I agree-- if you have a function that updates a number of global objects 
>or variables, you don't want to force yourself to list them all as 
>arguments every time you call the function.
>
>As a further note, I always use global statements in order to make objects 
>available to the local scope, but for looking at or updating regular 
>variables I tend to use the $GLOBALS array so that the local namespace 
>doesn't get to crowded.

aha, you mean like this?

$var1="something";
$var2="something else";
function dosomething($var1){
   global $GLOBALS;
   etc.


>    csnyder
>
>_______________________________________________
>talk mailing list
>talk at lists.nyphp.org
>http://lists.nyphp.org/mailman/listinfo/talk

Michael G. Southwell =================================
DNEBA Enterprises
81 South Road
Bloomingdale, NJ 07403-1419
973/492-7873 (voice and fax)
southwell at dneba.com
http://www.dneba.com
======================================================





More information about the talk mailing list