note 129497 added to functions.arguments
| From: | HayleyWatson | Date: | Thu, 16 May 2024 13:31:48 +0000 |
| Subject: | note 129497 added to functions.arguments | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-221328@lists.php.net to get a copy of this message | ||
The ... argument syntax will capture named arguments that don't correspond to actual function
parameters. These unknown named arguments will be ignored by functions like func_get_args(), but
they are available in the variadic parameter under the name they were given:
<?php
function demo($first, $second, ...$rest)
{
echo "First:";
var_dump($first);
echo "\n";
echo "Second:";
var_dump($second);
echo "\n";
echo "Rest:";
var_dump($rest);
echo "\n";
}
demo(1, third:3, second:2, fourth:4);
?>
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.13.131 (proxied: 222.152.65.7)
----
Manual Page -- https://php.net/manual/en/functions.arguments.php
Edit -- https://main.php.net/note/edit/129497
Del: integrated -- https://main.php.net/note/delete/129497/integrated
Del: useless -- https://main.php.net/note/delete/129497/useless
Del: bad code -- https://main.php.net/note/delete/129497/bad+code
Del: spam -- https://main.php.net/note/delete/129497/spam
Del: non-english -- https://main.php.net/note/delete/129497/non-english
Del: in docs -- https://main.php.net/note/delete/129497/in+docs
Del: other reasons-- https://main.php.net/note/delete/129497
Reject -- https://main.php.net/note/reject/129497
Search -- https://main.php.net/manage/user-notes.php