note 97469 deleted from function.unset by googleguy
| From: | googleguy@php.net | Date: | Wed, 19 Dec 2012 00:25:14 +0000 |
| Subject: | note 97469 deleted from function.unset by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-192587@lists.php.net to get a copy of this message | ||
Note Submitter: alexanderashleyboese at gmail dot com
----
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..."
?>