note 97469 added to function.unset

From: Date: Wed, 21 Apr 2010 18:09:03 +0000
Subject: note 97469 added to function.unset
Groups: php.notes 
Request: Send a blank email to php-notes+get-168480@lists.php.net to get a copy of this message
I have noticed that sometimes if you have a globally declared instantiation of a class, unsetting that instance does not always call destruct like you think it should. For instance, something like this might actually call the destruct later than implied by the "unset": <?php class Data { public function __destruct() { echo "These are my last words..."; } } function main(){ $data = new Data; one(); two(); } function one () { global $data; echo "Running 1st"; unset($data); } function two() { echo "Running 2nd"; } main(); //"Running 1stRunning 2ndThese are my last words..." ?> ---- Server IP: 69.147.83.197 Probable Submitter: 67.63.145.34 (proxied: 31.1.6.101) ---- Manual Page -- http://www.php.net/manual/en/function.unset.php Edit -- https://master.php.net/note/edit/97469 Del: integrated -- https://master.php.net/note/delete/97469/integrated Del: useless -- https://master.php.net/note/delete/97469/useless Del: bad code -- https://master.php.net/note/delete/97469/bad+code Del: spam -- https://master.php.net/note/delete/97469/spam Del: non-english -- https://master.php.net/note/delete/97469/non-english Del: in docs -- https://master.php.net/note/delete/97469/in+docs Del: other reasons-- https://master.php.net/note/delete/97469 Reject -- https://master.php.net/note/reject/97469 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#168480) next »