note 37427 added to language.variables.scope
| From: | Jack at soinsincere dot com | Date: | Fri, 14 Nov 2003 15:11:56 +0000 |
| Subject: | note 37427 added to language.variables.scope | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-60385@lists.php.net to get a copy of this message | ||
Alright, so you can't set a static variable with a reference.
However, you can set a static variable to an array with an element that is a reference:
<?php
class myReference {
function getOrSet($array = null) {
static $myValue;
if (!$array) {
return $myValue[0]; //Return reference in array
}
$myValue = $array; //Set static variable with array
static $myValue;
}
}
$static = "Dummy";
$dummy = new myReference;
$dummy->getOrSet(array(&$static));
$static = "Test";
print $dummy->getOrSet();
?>
----
Manual Page -- http://www.php.net/manual/en/language.variables.scope.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+37427
Delete -- http://master.php.net/manage/user-notes.php?action=delete+37427&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+37427&report=yes
Search -- http://master.php.net/manage/user-notes.php