Re: How to detect a PHP script time-out?

From: Date: Wed, 08 Jan 2003 07:16:56 +0000
Subject: Re: How to detect a PHP script time-out?
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-130715@lists.php.net to get a copy of this message
Timothy Hitchens ) wrote:
There is one last option ... register an output buffer as I suggested before suggested but this time do the reverse and you don't have to rewrite your scripts:
Ok I think I understand what you are proposing. I just have one question about your example code. Where does the string "Maximum execution" come from? Is this output automatically by PHP when a script times out? Would it be possible to use: if (connection_status == 2) {} Jc
<?php ob_start('scriptTimeout'); // set to 1 this should show the error below set to 2 and above you should get the normal output!! set_time_limit(1); function scriptTimeout($buffer) {
        if (eregi('Maximum execution', $buffer))
        {
                $buffer = 'Server Overloaded!!';
        }
        return $buffer;
} // // content area // for ($i = 0; $i < 1000000; $i++) {
        $output = $i;
} echo 'We are upto a final count of: '.$output; ?>


« previous php.general (#130715) next »