basic.phpt 538 B

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