note 90846 deleted from function.unset by danbrown
| From: | danbrown@php.net | Date: | Tue, 12 May 2009 18:54:32 +0000 |
| Subject: | note 90846 deleted from function.unset by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-154519@lists.php.net to get a copy of this message | ||
Note Submitter: LungZeno
----
continue...
<?php
function fun4(){
static $d = 'dd'; // fetch value which key 'd' in static variable array of
function fun4 refers to which was initialized last to value 'dddd' in compile-time, and
let local scope variable key 'd' refers to that value. Local scope variable key
'd' does not exist before, so create it.
debug_zval_dump(&$d);
static $d; // re-refer same value only
debug_zval_dump(&$d);
$d = 'dddddddddddddddd'; // change value of value which key 'd' in local
scope array and key 'd' in static variable array refer to to 'dddddddddddddddd'
unset($d); // destorys local scope variable key 'd'
var_dump(get_defined_vars());
debug_zval_dump(&$d);
var_dump(get_defined_vars());
$d = 'dddddddd'; // let local scope variable key 'd' refers to value
'dddddddd'. Local scope variable key 'd' does not exist in this moment, so
create it.
debug_zval_dump(&$d);
static $d = 'dddd'; // fetch value which key 'd' in static variable array
refer to which is 'dddddddddddddddd' in this moment, and let local scope variable key
'd' re-refers to that value.
debug_zval_dump(&$d);
}
echo "\n";
fun4();
/* display:
&string(2) "aa" refcount(2)
array(2) {
["a"]=>
&NULL
["a3"]=>
&NULL
}
&NULL refcount(2)
array(3) {
["a"]=>
&NULL
["a3"]=>
&NULL
["a4"]=>
NULL
}
&string(2) "bb" refcount(3)
&string(3) "bb3" refcount(3)
&string(3) "bb3" refcount(3)
&string(3) "bb2" refcount(3)
&string(3) "bb3" refcount(2)
array(2) {
["b"]=>
&string(2) "bb"
["b3"]=>
string(3) "bb3"
}
&string(3) "bb2" refcount(2)
array(3) {
["b"]=>
&string(2) "bb"
["b3"]=>
string(3) "bb3"
["b4"]=>
&NULL
}
array(8) {
["GLOBALS"]=>
array(8) {
["GLOBALS"]=>
*RECURSION*
["_POST"]=>
array(0) {
}
["_GET"]=>
array(0) {
}
["_COOKIE"]=>
array(0) {
}
["_FILES"]=>
array(0) {
}
["b"]=>
&string(2) "bb"
["b2"]=>
string(3) "bb2"
["b4"]=>
&NULL
}
["_POST"]=>
array(0) {
}
["_GET"]=>
array(0) {
}
["_COOKIE"]=>
array(0) {
}
["_FILES"]=>
array(0) {
}
["b"]=>
&string(2) "bb"
["b2"]=>
string(3) "bb2"
["b4"]=>
&NULL
}
&string(2) "cc" refcount(3)
&string(4) "dddd" refcount(3)
&string(4) "dddd" refcount(3)
array(0) {
}
&NULL refcount(2)
array(1) {
["d"]=>
NULL
}
&string(8) "dddddddd" refcount(2)
&string(16) "dddddddddddddddd" refcount(3)
*/
?>