Re: Deprecating "global" + $GLOBALS, making $_REQUEST, $_GET, $_POST read-only
| From: | Andrey Hristov | Date: | Thu, 09 Dec 2010 10:50:21 +0000 |
| Subject: | Re: Deprecating "global" + $GLOBALS, making $_REQUEST, $_GET, $_POST read-only | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-50931@lists.php.net to get a copy of this message | ||
Michael Shadle wrote:
On Thu, Dec 9, 2010 at 2:38 AM, Andrey Hristov <php@hristov.com> wrote:You can be creative and create ad-hoc objects with properties the variables you pass, but this is a kind of hack. Also reorganizing your code so not every function needs 6 parameters can help your code. Globals definitely don't help reusability. Best, AndreyYes, as the documentation will mention how to do it, for old applications. For new apps it is easy - pass all the information you need as parameter to the function. It works in other languages, why shouldn't it work for PHP?named parameters would help here. otherwise you wind up with a mess of argument hell. or passing a single array in and then in the function parsing that for the items (which is what I do, sort of a userland way of doing named parameters) but adding more and more parameters to functions over time leads to issues if they do not have default values and if you have to pass say, the 6th parameter, but don't need to pass the rest, etc.