003.phpt 1.2 KB

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. try {
  18. test2();
  19. } catch (Throwable $e) {
  20. echo "Exception: " . $e->getMessage() . "\n";
  21. }
  22. test3(1,2);
  23. call_user_func("test1");
  24. try {
  25. call_user_func("test3", 1);
  26. } catch (Throwable $e) {
  27. echo "Exception: " . $e->getMessage() . "\n";
  28. }
  29. call_user_func("test3", 1, 2);
  30. class test {
  31. static function test1($a) {
  32. var_dump(func_get_args());
  33. }
  34. }
  35. test::test1(1);
  36. var_dump(func_get_args());
  37. echo "Done\n";
  38. ?>
  39. --EXPECTF--
  40. array(0) {
  41. }
  42. array(1) {
  43. [0]=>
  44. int(10)
  45. }
  46. array(1) {
  47. [0]=>
  48. int(1)
  49. }
  50. Exception: Too few arguments to function test2(), 0 passed in %s003.php on line %d and exactly 1 expected
  51. array(2) {
  52. [0]=>
  53. int(1)
  54. [1]=>
  55. int(2)
  56. }
  57. array(0) {
  58. }
  59. Exception: Too few arguments to function test3(), 1 passed in %s003.php on line %d and exactly 2 expected
  60. array(2) {
  61. [0]=>
  62. int(1)
  63. [1]=>
  64. int(2)
  65. }
  66. array(1) {
  67. [0]=>
  68. int(1)
  69. }
  70. Warning: func_get_args(): Called from the global scope - no function context in %s on line %d
  71. bool(false)
  72. Done