php-src/Zend/tests/001.phpt

63 lines
1.0 KiB
Plaintext
Raw Normal View History

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);
try {
2020-02-03 21:52:20 +00:00
test2();
} catch (Throwable $e) {
2020-02-03 21:52:20 +00:00
echo "Exception: " . $e->getMessage() . "\n";
}
2006-06-27 21:10:04 +00:00
test3(1,2);
call_user_func("test1");
try {
2020-02-03 21:52:20 +00:00
call_user_func("test3", 1);
} catch (Throwable $e) {
2020-02-03 21:52:20 +00:00
echo "Exception: " . $e->getMessage() . "\n";
}
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);
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)
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)
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)
func_num_args() must be called from a function context
2006-06-27 21:10:04 +00:00
Done