Function returning reference
$r = 10;
$ref = & funcByRef("r");
$ref = 12;
print $r;
function &funcByRef($v) {
return $GLOBALS[$v];
}
Output:
12
Function Parameter - access by reference
$r = 10;
funcByRefParam($r);
print $r;
function funcByRefParam(&$v) {
$v--;
}
Output:
9
No comments:
Post a Comment