note 8978 deleted from functions.arguments by cmb
| From: | cmb@php.net | Date: | Sun, 10 Nov 2019 13:20:11 +0000 |
| Subject: | note 8978 deleted from functions.arguments by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-213027@lists.php.net to get a copy of this message | ||
Note Submitter: coop at better-mouse-trap dot com
----
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