2006-06-27 21:10:04 +00:00
|
|
|
--TEST--
|
|
|
|
func_num_args() tests
|
|
|
|
--FILE--
|
|
|
|
<?php
|
|
|
|
|
|
|
|
function test1() {
|
2020-02-03 21:52:20 +00:00
|
|
|
var_dump(func_num_args());
|
2006-06-27 21:10:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function test2($a) {
|
2020-02-03 21:52:20 +00:00
|
|
|
var_dump(func_num_args());
|
2006-06-27 21:10:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function test3($a, $b) {
|
2020-02-03 21:52:20 +00:00
|
|
|
var_dump(func_num_args());
|
2006-06-27 21:10:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
test1();
|
|
|
|
test2(1);
|
2016-06-15 23:32:02 +00:00
|
|
|
try {
|
2020-02-03 21:52:20 +00:00
|
|
|
test2();
|
2016-06-15 23:32:02 +00:00
|
|
|
} catch (Throwable $e) {
|
2020-02-03 21:52:20 +00:00
|
|
|
echo "Exception: " . $e->getMessage() . "\n";
|
2016-06-15 23:32:02 +00:00
|
|
|
}
|
|
|
|
|
2006-06-27 21:10:04 +00:00
|
|
|
test3(1,2);
|
|
|
|
|
|
|
|
call_user_func("test1");
|
2016-06-15 23:32:02 +00:00
|
|
|
try {
|
2020-02-03 21:52:20 +00:00
|
|
|
call_user_func("test3", 1);
|
2016-06-15 23:32:02 +00:00
|
|
|
} catch (Throwable $e) {
|
2020-02-03 21:52:20 +00:00
|
|
|
echo "Exception: " . $e->getMessage() . "\n";
|
2016-06-15 23:32:02 +00:00
|
|
|
}
|
2006-06-27 21:10:04 +00:00
|
|
|
call_user_func("test3", 1, 2);
|
|
|
|
|
|
|
|
class test {
|
2020-02-03 21:52:20 +00:00
|
|
|
static function test1($a) {
|
|
|
|
var_dump(func_num_args());
|
|
|
|
}
|
2006-06-27 21:10:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
test::test1(1);
|
2020-07-12 10:40:37 +00:00
|
|
|
|
|
|
|
try {
|
|
|
|
func_num_args();
|
|
|
|
} catch (Error $exception) {
|
|
|
|
echo $exception->getMessage() . "\n";
|
|
|
|
}
|
2006-06-27 21:10:04 +00:00
|
|
|
|
|
|
|
echo "Done\n";
|
|
|
|
?>
|
2018-09-16 17:16:42 +00:00
|
|
|
--EXPECTF--
|
2006-06-27 21:10:04 +00:00
|
|
|
int(0)
|
|
|
|
int(1)
|
2020-07-12 10:40:37 +00:00
|
|
|
Exception: Too few arguments to function test2(), 0 passed in %s on line %d and exactly 1 expected
|
2006-06-27 21:10:04 +00:00
|
|
|
int(2)
|
|
|
|
int(0)
|
2020-07-12 10:40:37 +00:00
|
|
|
Exception: Too few arguments to function test3(), 1 passed in %s on line %d and exactly 2 expected
|
2006-06-27 21:10:04 +00:00
|
|
|
int(2)
|
|
|
|
int(1)
|
2020-07-12 10:40:37 +00:00
|
|
|
func_num_args() must be called from a function context
|
2006-06-27 21:10:04 +00:00
|
|
|
Done
|