3 # this file is much like register_shutdown_function(), except:
5 # 1. it uses the standard name you know and love
7 # 2. wfpl will call it before calling display_messages() for you, or before
8 # calling session_save_messages() (when it's about to redirect.
10 $GLOBALS['wfpl_atexit_queue'] = array();
12 # your passed function will be called by run.php just before display_messages
13 # (or right before an http redirect)
16 function atexit($func, $args) {
17 $GLOBALS['wfpl_atexit_queue'][] = array($func, $args);
20 # call the functions queued up by atexit()
21 # atexit() can be called from one of these functions (even the last)
22 function atexit_now() {
23 while(count($GLOBALS['wfpl_atexit_queue'])) {
24 list($func, $args) = array_shift($GLOBALS['wfpl_atexit_queue']);
25 call_user_func_array($func, $args);
29 # for those cases where display_messages() and session_save_messages() don't
30 # get called automatically by wfpl:
31 register_shutdown_function("atexit_now");