note 70968 added to function.register-shutdown-function
| From: | docey at osu1 dot php dot net | Date: | Mon, 06 Nov 2006 20:17:21 +0000 |
| Subject: | note 70968 added to function.register-shutdown-function | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-119442@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 83.137.20.120
Probable Submitter: 62.216.10.14
----
Manual Page -- http://www.php.net/manual/en/function.register-shutdown-function.php
Edit -- https://master.php.net/note/edit/70968
Del: integrated -- https://master.php.net/note/delete/70968/integrated
Del: useless -- https://master.php.net/note/delete/70968/useless
Del: bad code -- https://master.php.net/note/delete/70968/bad+code
Del: spam -- https://master.php.net/note/delete/70968/spam
Del: non-english -- https://master.php.net/note/delete/70968/non-english
Del: in docs -- https://master.php.net/note/delete/70968/in+docs
Del: other reasons-- https://master.php.net/note/delete/70968
Reject -- https://master.php.net/note/reject/70968
Search -- https://master.php.net/manage/user-notes.php