I am implementing a page which does a database dump to CSV. This operation can take from 5 seconds to 10 minutes, depending on some parameters. I impelemented it using the register_shutdown_function. I was under the impression that the registered function would get called after the request was filled. Here is a quote from the manual:
The registered shutdown functions are called after the request has been completed (including sending any output buffers), so it is not possible to send output to the browser using echo() or print(), or retrieve the contents of any output buffers using ob_get_contents().
After tweaking a bit, it actually does work. The page displays, and the process continues to run. There is one small annoyance, however. The "globe" in the corner of IE is still spinning, indicating that the page is still loading. I can link away to a different page, and the background process will continue and finish normally. I'd just like to make the browser think the current page is done. Has anyone else had any experience with this? Below is the basic code which I am talking about. Thanks,
Chuck
<?php
function do_dump() {
// perform long operation here...
}
register_shutdown_function('do_dump');
set_time_limit(0);
ignore_user_abort(1);
// output HTML saying user will be e-mailed upon completion
session_write_close();
exit;
?>