xref: /PHP-8.4/Zend/tests/variadic/basic.phpt (revision 0d7a6388)
1--TEST--
2Basic variadic function
3--FILE--
4<?php
5
6function test1(... $args) {
7    var_dump($args);
8}
9
10test1();
11test1(1);
12test1(1, 2, 3);
13
14function test2($arg1, $arg2, ...$args) {
15    var_dump($arg1, $arg2, $args);
16}
17
18test2(1, 2);
19test2(1, 2, 3);
20test2(1, 2, 3, 4, 5);
21
22?>
23--EXPECT--
24array(0) {
25}
26array(1) {
27  [0]=>
28  int(1)
29}
30array(3) {
31  [0]=>
32  int(1)
33  [1]=>
34  int(2)
35  [2]=>
36  int(3)
37}
38int(1)
39int(2)
40array(0) {
41}
42int(1)
43int(2)
44array(1) {
45  [0]=>
46  int(3)
47}
48int(1)
49int(2)
50array(3) {
51  [0]=>
52  int(3)
53  [1]=>
54  int(4)
55  [2]=>
56  int(5)
57}
58