note 70968 deleted from function.register-shutdown-function by cmb
| From: | cmb@php.net | Date: | Sun, 03 Feb 2019 18:04:57 +0000 |
| Subject: | note 70968 deleted from function.register-shutdown-function by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-210180@lists.php.net to get a copy of this message | ||
Note Submitter: docey
----
if you want to make use of php5 __construct and _destruct functionality this functions is your
rescue.
so say you have a class called 'fiveclass', you need some code like this:
<?php
class fiveclass
{
function fiveclass()
{
return $this->__construct(); // forward php4 to __construct
}
function __construct()
{
// register __destruct method as shutdown function
register_shutdown_function(array(&$this, "__destruct"));
return true;
}
function __destruct()
{
// finish what where doing;
close_db();
flush_output();
write_cache_away();
return true;
}
}
$obj = new fiveclass();
?>
now you have the same functionality. __destruct is automaticly called at the end of your script.