xref: /PHP-8.0/tests/lang/func_num_args.004.phpt (revision f8d79582)
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_num_args());
8    $x = 'changed.x';
9    $y = 'changed.y';
10    var_dump(func_num_args());
11}
12
13function refVal(&$x, $y) {
14    var_dump($x, $y);
15    var_dump(func_num_args());
16    $x = 'changed.x';
17    $y = 'changed.y';
18    var_dump(func_num_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"
36int(2)
37int(2)
38string(9) "changed.y"
39
40
41-- Ref, Val --
42string(10) "original.b"
43string(10) "original.b"
44int(2)
45int(2)
46string(9) "changed.x"
47