summaryrefslogtreecommitdiff
path: root/tests/lang/returnByReference.002.phpt
blob: 99365f1b14414365ede01a19aab402c74cc7da25 (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
--TEST--
Returning a reference from a function.
--FILE--
<?php
function &returnRef() {
		global $a;
		return $a;
}

function returnVal() {
		global $a;
		return $a;
}

$a = "original";
$b =& returnVal();
$b = "changed";
var_dump($a); //expecting warning + "original" 

$a = "original";
$b =& returnRef();
$b = "changed";
var_dump($a); //expecting "changed" 
?>
--EXPECTF--

Notice: Only variables should be assigned by reference in %s on line 13
string(8) "original"
string(7) "changed"