note 128342 added to function.func-get-args
| From: | art at geigel dot com | Date: | Tue, 28 Mar 2023 15:32:43 +0000 |
| Subject: | note 128342 added to function.func-get-args | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-220300@lists.php.net to get a copy of this message | ||
The size of the array resulting from func_get_args(), for instance using count(), does not take into
account parameters that have been assigned default values in the function definition.
Example:
function foo($bar=true) {
echo count(func_get_args());
}
foo();
// echoes 0
foo("bar");
// echoes 1
A useful condition to test for when a function needs to return default behavior (whatever that might
be) when no value is present and the value of $bar could be true, false, null, etc.
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.13.130 (proxied: 2600:8806:9107:ab00:ad9c:b2a5:cb52:37e0)
----
Manual Page -- https://php.net/manual/en/function.func-get-args.php
Edit -- https://main.php.net/note/edit/128342
Del: integrated -- https://main.php.net/note/delete/128342/integrated
Del: useless -- https://main.php.net/note/delete/128342/useless
Del: bad code -- https://main.php.net/note/delete/128342/bad+code
Del: spam -- https://main.php.net/note/delete/128342/spam
Del: non-english -- https://main.php.net/note/delete/128342/non-english
Del: in docs -- https://main.php.net/note/delete/128342/in+docs
Del: other reasons-- https://main.php.net/note/delete/128342
Reject -- https://main.php.net/note/reject/128342
Search -- https://main.php.net/manage/user-notes.php