Passing Arguments and Returning Values by Reference
<?php
function add2(&$number) {
$number += 2;
return $number;
}
$mynum = 5;
$output = add2($mynum);
$output++;
echo "<p>output = {$output}, mynum = {$mynum}</p>\n";
function &initialize() {
$new = array_fill(0, 10, array_fill(0, 10, 0));
return $new;
}
$newarray =& initialize();
echo print_r($newarray, true);
?>
Related examples in the same category