Esempio n. 1
0
    <title>Passing Argument by Reference</title>
</head>

<body>

<?php 
function addFive($num)
{
    $num += 5;
}
function addSix(&$num)
{
    $num += 6;
}
$orignum = 10;
addFive($orignum);
echo "Original Value is {$orignum}<br />";
addSix($orignum);
echo "Original Value is {$orignum}<br />";
class Test
{
    public $i = 0;
}
function addFour(Test $t)
{
    $t->i += 4;
}
function addThree(Test &$t)
{
    $t->i += 3;
}
Esempio n. 2
0
<html>
<head>
<title>Passing Argument by Reference</title>
</head>
<body>
<?php 
function addFive($num)
{
    $num += 5;
}
function addSix(&$num)
{
    $num += 6;
}
$orignum = 10;
addFive(10);
echo "Original Value is {$orignum}<br />";
addSix($orignum);
echo "Original Value is {$orignum}<br />";
?>
</body>
</html>