note 107040 modified in function.func-get-args by danbrown
| From: | danbrown@php.net | Date: | Tue, 03 Jan 2012 21:47:26 +0000 |
| Subject: | note 107040 modified in function.func-get-args by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-185286@lists.php.net to get a copy of this message | ||
please note that optional parameters are not seen/passed by func_get_args(), as well as
func_get_arg().
ex:
<?php
function testfunc($optional = 'this argument is optional..') {
$args = func_get_args();
var_dump($args);
echo $optional;
}
?>
test case #1:
testfunc('argument no longer optional..');
result for #1:
array(1) {
[0]=> string(20) "argument no longer optional.."
}
argument no longer optional..
test case #2:
testfunc('argument no longer optional..','this is an extra argument');
result for #2:
array(2) {
[0]=> string(29) "argument no longer optional.."
[1]=> string(25) "this is an extra argument"
}
argument no longer optional..
test case #3: -- RESULTS IN AN EMPTY ARRAY
testfunc();
result for #3:
array(0) {
}
this argument is optional..
--was--
please note that optional parameters are not seen/passed by func_get_args(), as well as
func_get_arg().
ex:
function testfunc($optional = 'this argument is optional..') {
$args = func_get_args();
var_dump($args);
echo $optional;
}
test case #1:
testfunc('argument no longer optional..');
result for #1:
array(1) {
[0]=> string(20) "argument no longer optional.."
}
argument no longer optional..
test case #2:
testfunc('argument no longer optional..','this is an extra argument');
result for #2:
array(2) {
[0]=> string(29) "argument no longer optional.."
[1]=> string(25) "this is an extra argument"
}
argument no longer optional..
test case #3: -- RESULTS IN AN EMPTY ARRAY
testfunc();
result for #3:
array(0) {
}
this argument is optional..
http://php.net/manual/en/function.func-get-args.php