020.phpt 530 B

1234567891011121314151617181920212223242526272829
  1. --TEST--
  2. func_get_arg() invalid usage
  3. --FILE--
  4. <?php
  5. try {
  6. var_dump(func_get_arg(1));
  7. } catch (\Error $e) {
  8. echo $e->getMessage() . \PHP_EOL;
  9. }
  10. function bar() {
  11. var_dump(func_get_arg(1));
  12. }
  13. function foo() {
  14. bar(func_get_arg(1));
  15. }
  16. try {
  17. foo(1,2);
  18. } catch (\Error $e) {
  19. echo $e->getMessage() . \PHP_EOL;
  20. }
  21. ?>
  22. --EXPECT--
  23. func_get_arg() cannot be called from the global scope
  24. func_get_arg(): Argument #1 ($position) must be less than the number of the arguments passed to the currently executed function