Re: Named parameters

From: Date: Fri, 15 Oct 2010 17:27:37 +0000
Subject: Re: Named parameters
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-49913@lists.php.net to get a copy of this message
On Fri, Oct 15, 2010 at 10:26 AM, G M <gregory@gregory.net> wrote: > Okay so I am thinking about submitting a patch to PHP that would enable you to call functions > like this: > > stuff(1, 2, 'separator' => '<br>', 'clean' => true); I don't like having the never ending growing list of arguments issue, but I just use function foo($args = array()) { # first pass to normalize, check, scrub data $bar = isset($args['whatever']) ? intval($args['whatever']) : 0; # second pass to do sanity checking or business logic... if($bar > 0) { ... } } Looks like Drupal 7 is taking this approach with some things too. I am not sure the language itself needs anything to change, it can be done today and seems like an additional feature to shortcut something already available.

« previous php.internals (#49913) next »