note 22344 added to language.references.whatdo
| From: | ediaz1 at NO_SPAMwanadoo dot es | Date: | Fri, 14 Jun 2002 10:58:16 +0000 |
| Subject: | note 22344 added to language.references.whatdo | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-31853@lists.php.net to get a copy of this message | ||
The ampersand on the function's definitio does matter.
Try this:
----------------------------------------------------
function &crea_modifica_array()
{
static $miarray;
$miarray[1]++;
$miarray[2]++;
return($miarray);
}
$a=&crea_modifica_array();
echo $a[1]," ",$a[2],"<br>";
$b=&crea_modifica_array();
echo $b[1]," ",$b[2],"<br>";
$b[1]++;
echo $a[1];
----------------------------------------------------
It will return
1 1
2 2
3
as you expect.
If you try the above example *without* the ampersand on the function's definition (I mean,
function crea_modifica_array() {...)
the output will be
1 1
2 2
1
--
http://www.php.net/manual/en/language.references.whatdo.php
http://master.php.net/manage/user-notes.php?action=edit+22344
http://master.php.net/manage/user-notes.php?action=delete+22344
http://master.php.net/manage/user-notes.php?action=reject+22344