Re: Feature?
| From: | (Stig Sæther Bakken) | Date: | Tue, 25 Sep 2001 19:21:05 +0000 |
| Subject: | Re: Feature? | ||
| References: | 1 2 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-66587@lists.php.net to get a copy of this message | ||
[Hartmut Holzgraefe <hartmut@six.de>]
> Andy wrote:
>
> >In the case when I've few parameters I've to remember their order, so why not
> >$bar=foo('par2'=>10);
> >I want to pass value to only one or more but not to all params.
> >Also this will make the code clearer I think.
> >
> you can use arrays to mimic this behavior
>
> function foo($bar) {
> ...
> if(isset($bar['par2'])) ....
> ...
> }
>
> foo(array('par2'=>10));
Or even less:
function foo($bar) {
extract($bar);
...
if (isset($par2)) ....
...
}
It needs a defaulting mechanism though.
- Stig
--
Stig Sæther Bakken <ssb@alltheweb.com>
Fast Search & Transfer ASA, Trondheim, Norway