Welcome to Dream.In.Code
Become a PHP Expert!

Join 137,425 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,950 people online right now. Registration is fast and FREE... Join Now!




register_shutdown_function()

 
Reply to this topicStart new topic

register_shutdown_function()

grimpirate
16 Jan, 2008 - 05:44 PM
Post #1

D.I.C Head
Group Icon

Joined: 3 Aug, 2006
Posts: 197



Thanked: 5 times
Dream Kudos: 375
My Contributions
I got this code working now. Feel free to delete this thread.
CODE
<?php
// Running on a Windows XP machine with an Apache server
error_reporting(E_ALL);

ignore_user_abort(false); // Does indeed affect behavior now

function cleanup($filename){
    switch(connection_status()){
        case 1:
        unlink($filename);
        case 2:
        case 3:
        break;
    }
}

$filename = tempnam(getcwd(), 'tmp');

register_shutdown_function('cleanup', $filename);

set_time_limit(5);
// Purposely causes a CONNECTION_TIMEOUT
do{
    echo 'foo';
}while(true);
?>
Deletes the file only on a CONNECTION_ABORT and not on CONNECTION_TIMEOUT.

This post has been edited by grimpirate: 18 Jan, 2008 - 08:04 AM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/5/08 04:42AM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month