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