<?php
function increment($i)
{
$i++;
}
$i = 10;
increment($i);
echo $i;
?>
above function output is 10
Call by Reference -
<?php
function adder(&$str2)
{
$str2 .= 'Call By Reference';
}
$str = 'This is ';
adder($str);
echo $str;
?>
above returns output is 'this is call by reference'
use & (ampersand) symbol with formal arguments. The & represents reference of the variable.
No comments:
Post a Comment