Let this be last message in the thread. Thanks for the examples! I'll wait for PHP5. 
There is a possibility that this feature will
be in.

 Have fun

 Andrey Hristov
 IcyGEN Corporation
 http://www.icygen.com
 BALANCED SOLUTIONS

> ----- Original Message -----
> From: <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, September 26, 2001 2:42 PM
> Subject: Re: [PHP] Feature?
>
>
> > On Tue, 25 Sep 2001 09:36:57 -0500, you wrote:
> >
> > >>> <?php
> > >>> function foo($p)     { echo  $p['fred'] . $p['banana'];     }
> > >>> foo(array('fred' => 'hello', 'banana' => 'world'));
> > >>> ?>
> >
> > >> Yeap, I know that. I thought about this bit of hack but this breaks the
> > >> conception on giving parameters. Also this trick cannot
> > >> solve the problem with default parameters. If I have function with 5
> > >> params and all of them have default values and I want to pass
> > >> value only to the second parameter what I have to do?
> >
> > >Maybe this? A bit verbose, but functional.
> > ><?php
> > >function foo($p)
> > >{
> > >   if (empty($p['fred']))
> > >     $p['fred'] = 'hello'; // same for banana
> > >   echo  $p['fred'] . $p['banana'];
> > >}
> > >foo(array('fred' => 'hello', 'banana' => 'world'));
> > >?>
> > >steve
> >
> > I'm not keen on adding lots of multi-line if statements - I prefer tp
> > put things into arrays where I can.  Easier to update them.
> >
> > <?php
> > function foo($p)
> > {
> > $foodefault = array( // prefix matching the name in 'extract'
> > 'foo_fred'=> '<strong>default fred</strong>',
> > 'foo_banana' => '<strong>default bananananana</strong>',
> > );
> > extract ($p, EXTR_PREFIX_ALL, 'foo'); // get params
> > extract ($foodefault, EXTR_SKIP, "foo"); // get defaults
> > echo  "$foo_fred / $foo_banana";
> > }
> > echo "Both in place: ";
> > foo(array('fred' => 'hello', 'banana' => 'world'));
> > echo "<br /> Now with a missing param: ";
> > foo(array('fred' => 'hello'));
> > echo "<br /> Now both missing params: ";
> > foo(array());
> > ?>
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> >
> >
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to