func_get_arg_variation.phpt 519 B

1234567891011121314151617181920212223242526
  1. --TEST--
  2. func_get_arg test
  3. --FILE--
  4. <?php
  5. function foo($a)
  6. {
  7. $a=5;
  8. try {
  9. echo func_get_arg(-1);
  10. } catch (\Error $e) {
  11. echo $e->getMessage() . \PHP_EOL;
  12. }
  13. try {
  14. echo func_get_arg(2);
  15. } catch (\Error $e) {
  16. echo $e->getMessage() . \PHP_EOL;
  17. }
  18. }
  19. foo(2);
  20. ?>
  21. --EXPECT--
  22. func_get_arg(): Argument #1 ($position) must be greater than or equal to 0
  23. func_get_arg(): Argument #1 ($position) must be less than the number of the arguments passed to the currently executed function