Named parameters
Emmanuel. M. Decarie
emm at scriptdigital.com
Fri May 9 16:03:09 EDT 2003
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
--
______________________________________________________________________
Emmanuel Décarie / Programmation pour le Web - Programming for the Web
Radio UserLand/Frontier - Perl - PHP - Javascript <http://scriptdigital.com/>
Blog: <http://blog.scriptdigital.com> - AIM: scriptdigital
More information about the talk
mailing list