xref: /PHP-5.3/Zend/tests/002.phpt (revision 41ada4ba)
1--TEST--
2func_get_arg() tests
3--FILE--
4<?php
5
6function test1() {
7	var_dump(func_get_arg(-10));
8	var_dump(func_get_arg(0));
9	var_dump(func_get_arg(1));
10}
11
12function test2($a) {
13	var_dump(func_get_arg(0));
14	var_dump(func_get_arg(1));
15}
16
17function test3($a, $b) {
18	var_dump(func_get_arg(0));
19	var_dump(func_get_arg(1));
20	var_dump(func_get_arg(2));
21}
22
23test1();
24test1(10);
25test2(1);
26test2();
27test3(1,2);
28
29call_user_func("test1");
30call_user_func("test3", 1);
31call_user_func("test3", 1, 2);
32
33class test {
34	static function test1($a) {
35		var_dump(func_get_arg(0));
36		var_dump(func_get_arg(1));
37	}
38}
39
40test::test1(1);
41var_dump(func_get_arg(1));
42
43echo "Done\n";
44?>
45--EXPECTF--
46Warning: func_get_arg():  The argument number should be >= 0 in %s on line %d
47bool(false)
48
49Warning: func_get_arg():  Argument 0 not passed to function in %s on line %d
50bool(false)
51
52Warning: func_get_arg():  Argument 1 not passed to function in %s on line %d
53bool(false)
54
55Warning: func_get_arg():  The argument number should be >= 0 in %s on line %d
56bool(false)
57int(10)
58
59Warning: func_get_arg():  Argument 1 not passed to function in %s on line %d
60bool(false)
61int(1)
62
63Warning: func_get_arg():  Argument 1 not passed to function in %s on line %d
64bool(false)
65
66Warning: Missing argument 1 for test2(), called in %s on line %d and defined in %s on line %d
67
68Warning: func_get_arg():  Argument 0 not passed to function in %s on line %d
69bool(false)
70
71Warning: func_get_arg():  Argument 1 not passed to function in %s on line %d
72bool(false)
73int(1)
74int(2)
75
76Warning: func_get_arg():  Argument 2 not passed to function in %s on line %d
77bool(false)
78
79Warning: func_get_arg():  The argument number should be >= 0 in %s on line %d
80bool(false)
81
82Warning: func_get_arg():  Argument 0 not passed to function in %s on line %d
83bool(false)
84
85Warning: func_get_arg():  Argument 1 not passed to function in %s on line %d
86bool(false)
87
88Warning: Missing argument 2 for test3() in %s on line %d
89int(1)
90
91Warning: func_get_arg():  Argument 1 not passed to function in %s on line %d
92bool(false)
93
94Warning: func_get_arg():  Argument 2 not passed to function in %s on line %d
95bool(false)
96int(1)
97int(2)
98
99Warning: func_get_arg():  Argument 2 not passed to function in %s on line %d
100bool(false)
101int(1)
102
103Warning: func_get_arg():  Argument 1 not passed to function in %s on line %d
104bool(false)
105
106Warning: func_get_arg():  Called from the global scope - no function context in %s on line %d
107bool(false)
108Done
109