Re: Re: How Do I make Global Scope Variables AvailabletoFunctions
| From: | Christoph M. Becker | Date: | Tue, 29 May 2018 20:06:32 +0000 |
| Subject: | Re: Re: How Do I make Global Scope Variables AvailabletoFunctions | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-326496@lists.php.net to get a copy of this message | ||
On 29.05.2018 at 16:18, John wrote:
> Thanks for your reply Christoph. From your and other comments it appears that I
> can't do what I was trying to do.
>
> On the one hand, it is satisfying that I wasn't making a mistake; on the other,
> I sure wish there was a way to avoid passing all these variables in PHP! In a
> way it makes the "function" command far less valuable than it should be!
On the contrary, I'd say! If I see a variable inside a function body, I
almost immediately know that it is a local variable or a function
parameter (or a superglobal), unless there is a global “declaration”.
Even better, each time I add a global “declaration”, I'm reminded to
think of a better way to express myself, and if I see a lengthy list of
globals, I know that the code will be hard to maintain. See also
<http://wiki.c2.com/?GlobalVariablesAreBad>.
--
Christoph M. Becker