php register_shutdown_function 的一个问题
php register_shutdown_function 方法执行顺序是
1,调用 register_shutdown_function 注册方法
2,调用类析构方法
3,输出
因为是先调用 register_shutdown_function 注册的方法,后调用析构方法,所以类的析构操作都将在 register_shutdown_function完成之后才能执行。
// php7.0.6线上版本
// 代码路径:php-src/main/main.c
void php_request_shutdown(void *dummy)
{
……
/* 1. Call all possible shutdown functions registered with register_shutdown_function() */
if (PG(modules_activated)) zend_try {
php_call_shutdown_functions();
} zend_end_try();
/* 2. Call all possible __destruct() functions */
zend_try {
zend_call_destructors();
} zend_end_try();
/* 3. Flush all output buffers */
zend_try {
……
}
最后更新于 2020-09-01 07:31:10 并被添加「」标签,已有 2891 位童鞋阅读过。
本站使用「署名 4.0 国际」创作共享协议,可自由转载、引用,但需署名作者且注明文章出处