Hi everybody,
recently I stumbled over the register_shutdown_function(string func) function. It tells PHP to execute the function given in string func after processing the entire script. The manual also suggests to use this function as destructor in classes.
Now let's asume I have a class like this:
class foo {
function foo()
echo "this is the constructor";
register_shutdown_function("endthis");
// do stuff...
}
//--- more functions
function endthis() {
// this is the destructor
exec("touch /tmp/" . date("YmdHis"));
// touching a file to verify execution
}
}
The function endthis() is NOT executed. I tried several other calls like:
register_shutdown_function("this->endthis"); with $, without $, escaped, ... but to no effect.
It seems to me that only non_class functions can be called with this function, which would prove the manual wrong.
Has anybody experienced the same or knows what I did wrong? Also, are there other good methods to implement destructors?
Thanks in advance,
Dominique
P.S.: Plattform: Linux, Apache 1.3, PHP 4.0.6