note 77207 added to function.func-get-args
| From: | Sinured at osu1 dot php dot net | Date: | Mon, 20 Aug 2007 12:38:35 +0000 |
| Subject: | note 77207 added to function.func-get-args | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-129636@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 212.124.37.9
Probable Submitter: 85.176.230.159
----
Manual Page -- http://www.php.net/manual/en/function.func-get-args.php
Edit -- https://master.php.net/note/edit/77207
Del: integrated -- https://master.php.net/note/delete/77207/integrated
Del: useless -- https://master.php.net/note/delete/77207/useless
Del: bad code -- https://master.php.net/note/delete/77207/bad+code
Del: spam -- https://master.php.net/note/delete/77207/spam
Del: non-english -- https://master.php.net/note/delete/77207/non-english
Del: in docs -- https://master.php.net/note/delete/77207/in+docs
Del: other reasons-- https://master.php.net/note/delete/77207
Reject -- https://master.php.net/note/reject/77207
Search -- https://master.php.net/manage/user-notes.php