note 48484 modified in language.references.pass by danbrown
| From: | danbrown@php.net | Date: | Thu, 28 Jan 2010 13:20:48 +0000 |
| Subject: | note 48484 modified in language.references.pass by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-165425@lists.php.net to get a copy of this message | ||
Just a simple note...
<?php
$num = 1;
function blah(&$var)
{
$var++;
}
blah($num);
echo $num; #2
?>
<?php
$num = 1;
function blah()
{
$var =& $GLOBALS["num"];
$var++;
}
blah();
echo $num; #2
?>
Both codes do the same thing! The second code "explains" how passage of parameters by
reference works.
--was--
Just a simple note...
<?
$num = 1;
function blah(&$var)
{
$var++;
}
blah($num);
echo $num; #2
?>
<?
$num = 1;
function blah()
{
$var =& $GLOBALS["num"];
$var++;
}
blah();
echo $num; #2
?>
Both codes do the same thing! The second code "explains" how passage of parameters by
reference works.
http://php.net/manual/en/language.references.pass.php