Can you unregister a shutdown function?

后端 未结 2 1718
遇见更好的自我
遇见更好的自我 2020-12-24 02:17

Is it possible in PHP to unregister a function (or all functions) set up with register_shutdown_function()?

2条回答
  •  情书的邮戳
    2020-12-24 02:44

    Hi I made a slight modification to the way my function worked as follows:

    function onDie(){
        global $global_shutdown;
    
        if($global_shutdown){
            //do shut down
        }
    }
    
    $global_shutdown = true;
    register_shutdown_function('onDie'); 
    
    //do code stuff until function no longer needed.
    
    $global_shutdown = false;
    

提交回复
热议问题