Showing posts with label local var. Show all posts
Showing posts with label local var. Show all posts
How do you pass a variable by Reference?
Posted by Raj
Example:
<?php
function test (&$a)
{
$a++;
}
$b=10;
test ($b);
// $b is 11 here
?>
You can assign default value to pass-by-reference paramter.
<?php
function test(&$arg = 1) {
if ($arg == 1) {
echo $arg;
}
}
test();
?>