Re: [PHP] Re: How Do I make Global Scope Variables AvailabletoFunctions
- Date: Tue, 29 May 2018 22:06:32 +0200
- From: "Christoph M. Becker" <cmbecker69@xxxxxx>
- Subject: Re: [PHP] Re: How Do I make Global Scope Variables AvailabletoFunctions
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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php