In PHP is it possible to register a shutdown function (with register_shutdown_function()
) which is a static method implemented in a class? I mean something like this:
//index.php
require_once("modules/Analyzer/Analyzer.php");
register_shutdown_function("Analyzer::log_shutdown");
//Analyzer.php
class Analyzer {
...
public static function log_shutdown(){
// do some awesome stuff
Analyzer::screenshot();
}
}
The first argument passed to register_shutdown_function is of the type callable. A callable static method looks like this:
register_shutdown_function(array('Analyzer', 'log_shutdown'));
As of PHP 5.2.3 it may also look exactly like what you originally posted
Can use an anonymous function:
register_shutdown_function(function(){
Analyzer::log_shutdown();
});
also, in analyzer you can use a call to the same class like this:
class Analyzer{
public static function log_shutdown(){
self::screenshot();
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With