mirror of
https://github.com/php/php-src.git
synced 2024-09-29 22:06:09 +00:00
0d7a638866
As per RFC: https://wiki.php.net/rfc/variadics
58 lines
538 B
PHP
58 lines
538 B
PHP
--TEST--
|
|
Basic variadic function
|
|
--FILE--
|
|
<?php
|
|
|
|
function test1(... $args) {
|
|
var_dump($args);
|
|
}
|
|
|
|
test1();
|
|
test1(1);
|
|
test1(1, 2, 3);
|
|
|
|
function test2($arg1, $arg2, ...$args) {
|
|
var_dump($arg1, $arg2, $args);
|
|
}
|
|
|
|
test2(1, 2);
|
|
test2(1, 2, 3);
|
|
test2(1, 2, 3, 4, 5);
|
|
|
|
?>
|
|
--EXPECT--
|
|
array(0) {
|
|
}
|
|
array(1) {
|
|
[0]=>
|
|
int(1)
|
|
}
|
|
array(3) {
|
|
[0]=>
|
|
int(1)
|
|
[1]=>
|
|
int(2)
|
|
[2]=>
|
|
int(3)
|
|
}
|
|
int(1)
|
|
int(2)
|
|
array(0) {
|
|
}
|
|
int(1)
|
|
int(2)
|
|
array(1) {
|
|
[0]=>
|
|
int(3)
|
|
}
|
|
int(1)
|
|
int(2)
|
|
array(3) {
|
|
[0]=>
|
|
int(3)
|
|
[1]=>
|
|
int(4)
|
|
[2]=>
|
|
int(5)
|
|
}
|