note 77207 deleted from function.func-get-args by peehaa
| From: | peehaa@php.net | Date: | Mon, 08 Apr 2019 06:13:26 +0000 |
| Subject: | note 77207 deleted from function.func-get-args by peehaa | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-210556@lists.php.net to get a copy of this message | ||
Note Submitter: Sinured
----
It may seem obvious, but if you want your variadic function to at least require one parameter, you
can do this instead of checking func_num_args() == 0, which I've seen often:
<?php
function variadic($dummy) {
$args = func_get_args();
foreach ($args as $arg) {
echo "$arg<br />\n";
}
}
?>
func_get_args() fetches ALL passed parameters, not only those that weren't copied to a local
variable.