RE: [PHP] How to detect a PHP script time-out?

From: Date: Wed, 08 Jan 2003 07:35:48 +0000
Subject: RE: [PHP] How to detect a PHP script time-out?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-130718@lists.php.net to get a copy of this message
No you can't.. the issue with this is that you need to have error reporting turned on.. so you will need to have more error collecting or removing. The error is something like: "Fatal error: Maximum execution......" so we are checking for just this in the regex. This isn't the best for a production env but this is the best I can see considering you don't want to rewrite!! Timothy Hitchens (HiTCHO) Open Platform Consulting e-mail: tim@hitcho.com.au > -----Original Message----- > From: Jean-Christian Imbeault [mailto:jc@mega-bucks.co.jp] > Sent: Wednesday, 8 January 2003 5:17 PM > To: php-general@lists.php.net > Subject: Re: [PHP] How to detect a PHP script time-out? > > > 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; > > > > ?> > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#130718) next »