NYCPHP Meetup

NYPHP.org

[nycphp-talk] Named parameters

Brent Baisley brent at landover.com
Fri May 9 16:48:59 EDT 2003


Not quite sure what you are asking, but you may want to look into the 
extract() function. It converts an array into variables using the array 
keys for the name of the variables.

On Friday, May 9, 2003, at 04:04 PM, Emmanuel. M. Decarie wrote:

> I miss named parameters for function in PHP.
>
> Is there a better way to do it than that:
>
> function namedParams ( $ar ) {
> 	echo $ar['param1'] . " " . $ar['param2'];
> }
>
> namedParams ( array ('param1' => "Hello", 'param2' => "World!") );
>
> --> Hello World!
>
> I could have done something like:
>
> $params = array (
> 	'param1' => "Hello",
> 	'param2' => "World!");
> namedParams ($params);
>
> But my feeling is that in both case, it look ugly.
>
> Usually, named parameters are there for readability, which, in my
> example, is not really the case.
>
> Is there any technique that I'm missing here?
>
> Cheers
> -Emmanuel
>
-- 
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search & Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577




More information about the talk mailing list