xref: /PHP-5.6/tests/lang/func_get_args.004.phpt (revision 775389cd)
1--TEST--
2Pass same variable by ref and by value.
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--EXPECTF--
33
34-- Val, Ref --
35string(10) "original.a"
36string(10) "original.a"
37array(2) {
38  [0]=>
39  string(10) "original.a"
40  [1]=>
41  string(10) "original.a"
42}
43array(2) {
44  [0]=>
45  string(10) "original.a"
46  [1]=>
47  string(9) "changed.y"
48}
49string(9) "changed.y"
50
51
52-- Ref, Val --
53string(10) "original.b"
54string(10) "original.b"
55array(2) {
56  [0]=>
57  string(10) "original.b"
58  [1]=>
59  string(10) "original.b"
60}
61array(2) {
62  [0]=>
63  string(9) "changed.x"
64  [1]=>
65  string(10) "original.b"
66}
67string(9) "changed.x"