003.phpt 1014 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. --TEST--
  2. func_get_args() tests
  3. --FILE--
  4. <?php
  5. function test1() {
  6. var_dump(func_get_args());
  7. }
  8. function test2($a) {
  9. var_dump(func_get_args());
  10. }
  11. function test3($a, $b) {
  12. var_dump(func_get_args());
  13. }
  14. test1();
  15. test1(10);
  16. test2(1);
  17. test2();
  18. test3(1,2);
  19. call_user_func("test1");
  20. call_user_func("test3", 1);
  21. call_user_func("test3", 1, 2);
  22. class test {
  23. static function test1($a) {
  24. var_dump(func_get_args());
  25. }
  26. }
  27. test::test1(1);
  28. var_dump(func_get_args());
  29. echo "Done\n";
  30. ?>
  31. --EXPECTF--
  32. array(0) {
  33. }
  34. array(1) {
  35. [0]=>
  36. int(10)
  37. }
  38. array(1) {
  39. [0]=>
  40. int(1)
  41. }
  42. Warning: Missing argument 1 for test2(), called in %s on line %d and defined in %s on line %d
  43. array(0) {
  44. }
  45. array(2) {
  46. [0]=>
  47. int(1)
  48. [1]=>
  49. int(2)
  50. }
  51. array(0) {
  52. }
  53. Warning: Missing argument 2 for test3() in %s on line %d
  54. array(1) {
  55. [0]=>
  56. int(1)
  57. }
  58. array(2) {
  59. [0]=>
  60. int(1)
  61. [1]=>
  62. int(2)
  63. }
  64. array(1) {
  65. [0]=>
  66. int(1)
  67. }
  68. Warning: func_get_args(): Called from the global scope - no function context in %s on line %d
  69. bool(false)
  70. Done