summaryrefslogtreecommitdiff
path: root/tests/lang/passByReference_010.phpt
blob: 431659a24a41367f9d9c1b9ae6c7f06fe04bb4d3 (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
--TEST--
Passing assignments by reference
--FILE--
<?php

function f(&$a) {
  var_dump($a);
  $a = "a.changed";
}

echo "\n\n---> Pass constant assignment by reference:\n";
f($a="a.original");
var_dump($a);

echo "\n\n---> Pass variable assignment by reference:\n";
unset($a);
$a = "a.original";
f($b = $a);
var_dump($a);

echo "\n\n---> Pass reference assignment by reference:\n";
unset($a, $b);
$a = "a.original";
f($b =& $a);
var_dump($a);

echo "\n\n---> Pass concat assignment by reference:\n";
unset($a, $b);
$b = "b.original";
$a = "a.original";
f($b .= $a);
var_dump($a);

?>
--EXPECTF--


---> Pass constant assignment by reference:

Notice: Only variables should be passed by reference in %s on line 9
string(10) "a.original"
string(10) "a.original"


---> Pass variable assignment by reference:

Notice: Only variables should be passed by reference in %s on line 15
string(10) "a.original"
string(10) "a.original"


---> Pass reference assignment by reference:
string(10) "a.original"
string(9) "a.changed"


---> Pass concat assignment by reference:

Notice: Only variables should be passed by reference in %s on line 28
string(20) "b.originala.original"
string(10) "a.original"