note 39373 deleted from function.unset by tomsommer
| From: | tomsommer@php.net | Date: | Mon, 28 Jun 2004 15:19:21 +0000 |
| Subject: | note 39373 deleted from function.unset by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-72049@lists.php.net to get a copy of this message | ||
Note Submitter: warhog at warhog dot net
----
on the comment by dh at argosign dot de
it IS possible to unset global variables out of a function, you just have to use the superglobe
$GLOBALS
here the code corrected so it would work!
<?php $x = 10;
function test() {
unset ($GLOBALS['x']);
echo "x: $x<br>";
}
test();
echo "x: $x<br>"; ?>
the examlpe would give the result
x:
x:
now, and depending on the error_report level notices about undefined variables!