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