xref: /php-src/tests/lang/func_get_args.004.phpt (revision f8d79582)
1--TEST--
2Pass same variable by ref and by value (PHP7).
3--FILE--
4<?php
5function valRef($x, &$y) {
6    var_dump($x, $y);
7    var_dump(func_get_args());
8    $x = 'changed.x';
9    $y = 'changed.y';
10    var_dump(func_get_args());
11}
12
13function refVal(&$x, $y) {
14    var_dump($x, $y);
15    var_dump(func_get_args());
16    $x = 'changed.x';
17    $y = 'changed.y';
18    var_dump(func_get_args());
19}
20
21
22echo "\n\n-- Val, Ref --\n";
23$a = 'original.a';
24valRef($a, $a);
25var_dump($a);
26
27echo "\n\n-- Ref, Val --\n";
28$b = 'original.b';
29refVal($b, $b);
30var_dump($b);
31?>
32--EXPECT--
33-- Val, Ref --
34string(10) "original.a"
35string(10) "original.a"
36array(2) {
37  [0]=>
38  string(10) "original.a"
39  [1]=>
40  string(10) "original.a"
41}
42array(2) {
43  [0]=>
44  string(9) "changed.x"
45  [1]=>
46  string(9) "changed.y"
47}
48string(9) "changed.y"
49
50
51-- Ref, Val --
52string(10) "original.b"
53string(10) "original.b"
54array(2) {
55  [0]=>
56  string(10) "original.b"
57  [1]=>
58  string(10) "original.b"
59}
60array(2) {
61  [0]=>
62  string(9) "changed.x"
63  [1]=>
64  string(9) "changed.y"
65}
66string(9) "changed.x"
67