|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2000-10-01 06:21 UTC] rubein at earthlink dot net
[2000-10-01 06:57 UTC] waldschrott@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 20 21:00:02 2025 UTC |
script: <? class TEST { var $foo; } function one() { global $object; $object = new TEST(); $object->foo = "bar"; echo "\none() dump of object before unset\n"; var_dump($object); unset($object); echo "\none() dump of object after unset\n"; var_dump($object); two(); } function two() { global $object; echo "\ntwo() dump of object after unset\n"; var_dump($object); } echo "<PRE>\n"; one(); echo "\n(no function) dump of object after unset\n"; var_dump($object); produces: one() dump of object before unset object(test)(1) { ["foo"]=> string(3) "bar" } one() dump of object after unset NULL two() dump of object after unset object(test)(1) { ["foo"]=> string(3) "bar" } (no function) dump of object after unset object(test)(1) { ["foo"]=> string(3) "bar" } unset()ing an globally defined object within a function doesn't unset it globally - it can still be referred to in other functions.