note 8978 modified in functions.arguments by felipe
| From: | felipe@php.net | Date: | Tue, 22 Jul 2008 02:19:36 +0000 |
| Subject: | note 8978 modified in functions.arguments by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-142456@lists.php.net to get a copy of this message | ||
If you prefer to use named arguments to your functions (so you don't have to worry about the
order of variable argument lists), you can do so PERL style with anonymous arrays:
<?php
function foo($args)
{
print "named_arg1 : " . $args["named_arg1"] . "\n";
print "named_arg2 : " . $args["named_arg2"] . "\n";
}
foo(array("named_arg1" => "arg1_value", "named_arg2" =>
"arg2_value"));
?>
will output:
named_arg1 : arg1_value
named_arg2 : arg2_value
--was--
If you prefer to use named arguments to your functions (so you don't have to worry about the
order of variable argument lists), you can do so PERL style with anonymous arrays:
function foo($args)
{
print "named_arg1 : " . $args["named_arg1"] . "\n";
print "named_arg2 : " . $args["named_arg2"] . "\n";
}
foo(array("named_arg1" => "arg1_value", "named_arg2" =>
"arg2_value"));
====== will output: =======
named_arg1 : arg1_value
named_arg2 : arg2_value
http://php.net/manual/en/functions.arguments.php