Re: Deprecating "global" + $GLOBALS, making $_REQUEST, $_GET, $_POST read-only
| From: | Alain Williams | Date: | Thu, 09 Dec 2010 12:27:47 +0000 |
| Subject: | Re: Deprecating "global" + $GLOBALS, making $_REQUEST, $_GET, $_POST read-only | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-50944@lists.php.net to get a copy of this message | ||
On Thu, Dec 09, 2010 at 01:15:41PM +0100, Andrey Hristov wrote:
> no, you got me wrong. I will repeat - global variables won't cease to
> exist, but $GLOBALS and "global" as means to access them should be
> removed. If a function needs data it should get it passed to it.
By & large yes, but in small/medium scripts it can be really useful
to have things like a globally scoped $dbh - so it doesn't clutter up
function calls. Yes: if the script grows to the point where it needs
more than one database handle then the script will need to be refactored,
but for huge numbers of scripts that will never be the case.
If you ban global variables people will just bung the values into
$_SESSION to get the same effect -- that would be even worse!
--
Alain Williams
Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer.
+44 (0) 787 668 0256 http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: http://www.phcomp.co.uk/contact.php
#include <std_disclaimer.h>