|
Posted by Chuck Anderson on 10/24/30 11:18
Andy Hassall wrote:
>On Wed, 08 Jun 2005 19:06:52 -0600, Chuck Anderson <websiteaddress@seemy.sig>
>wrote:
>
>
>
>>I have a function with 7 inputs. The last three have default values.
>>
>>I want to call that function specifying the first four, skip two and
>>then specify the last.
>>
>>I thought I could write this as :
>>
>>$retval = myfunction(arg1, arg2, arg3, arg4,,,arg7);
>>
>>... but Php does not seem to want to let me do this. I get a parse
>>error until I supply values for the 5th and 6th arguments.
>>
>>My question is simply this; is skipping arguments like that not allowed
>>in Php?
>>
>>
>
> It's not allowed.
>
> One alternative if you want to skip any argument and you can't rearrange the
>skippable ones all towards the end is to pass an associative array instead,
>which make it looks like named parameters from other languages, e.g.:
>
>myfunction(array(
> arg2 => 'wibble',
> arg6 => 'wobble'
>));
>
>
>
Thanks. Yes, ... I can make "other arrangements." I just wanted to be
sure that was "illegal" before I wrote off ever trying it again.
--
*****************************
Chuck Anderson • Boulder, CO
http://www.CycleTourist.com
Integrity is obvious.
The lack of it is common.
*****************************
Navigation:
[Reply to this message]
|