>
PHP提供register_shutdown_function()这个函数,能够在脚本终止前回调注册的函数
register_shutdown_function例子代码:
以下为引用的内容: <?php |
There is a note "Shutdown function is called during the script shutdown so headers are always already sent.", but my php 5.1 seems to act differently.
Example:
以下为引用的内容: <?php class Test { private $running; public function main() { $this->running = true; ob_start(); error_reporting(E_ALL); register_shutdown_function(array($this, "clean_exit")); echo "Hello"; // triggers E_ERROR $fatal->error(); $this->running = false; }
public function clean_exit() { |