3 # This program is in the public domain within the United States. Additionally,
4 # we waive copyright and related rights in the work worldwide through the CC0
5 # 1.0 Universal public domain dedication, which can be found at
6 # http://creativecommons.org/publicdomain/zero/1.0/
8 # this file is much like register_shutdown_function(), except:
10 # 1. it uses the standard name you know and love
12 # 2. wfpl will call it before calling display_messages() for you, or before
13 # calling session_save_messages() (when it's about to redirect.
15 $GLOBALS['wfpl_atexit_queue'] = array();
17 # your passed function will be called by run.php just before display_messages
18 # (or right before an http redirect)
21 function atexit($func, $args) {
22 $GLOBALS['wfpl_atexit_queue'][] = array($func, $args);
25 # call the functions queued up by atexit()
26 # atexit() can be called from one of these functions (even the last)
27 function atexit_now() {
28 while(count($GLOBALS['wfpl_atexit_queue'])) {
29 list($func, $args) = array_shift($GLOBALS['wfpl_atexit_queue']);
30 call_user_func_array($func, $args);
34 # for those cases where display_messages() and session_save_messages() don't
35 # get called automatically by wfpl:
36 register_shutdown_function("atexit_now");