Re: Re: Named Parameters
| From: | Pierre Joye | Date: | Mon, 12 Apr 2010 23:17:21 +0000 |
| Subject: | Re: Re: Named Parameters | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-47897@lists.php.net to get a copy of this message | ||
On Tue, Apr 13, 2010 at 1:10 AM, Stanislav Malyshev <stas@zend.com> wrote:
> Hi!
>
>> Proposed new syntax of this case:
>>
>> function foo($x,$y){
>> $options = func_get_args();
>> if ( !isset($options['opt1']) ) $options['opt1'] = 'foo';
>> if ( !isset($options['opt2']) ) $options['opt2'] = 'bar';
>> /* 1 */
>> }
>
> I think the idea is to do:
>
> function foo($x,$y, $opt1 = 'foo', $opt2 = 'bar'){
> }
> foo(1,2);
> foo(1,2,'opt1'=>'no-foo');
>
That's the idea if we can't do (1, opt1 = 'foo') or?
Cheers,
--
Pierre
@pierrejoye | http://blog.thepimp.net | http://www.libgd.org