Re: Re: Register_Shutdown_Function ??

From: Date: Sun, 19 May 2002 04:16:11 +0000
Subject: Re: Re: Register_Shutdown_Function ??
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-98486@lists.php.net to get a copy of this message
Windows? Blah. This stuff may very well not work there. No idea. -Rasmus On Sat, 18 May 2002, Jason Caldwell wrote: > It doesn't matter. I'm setting the output *not* to the browser, but to the > command shell, where I am running the script from. If you look at the > errors, you'll see 2 of them, one points to line 7, where the IF() command > is -- the script terminates there... > > I've put error_log() and exec() functions in place of the print() > function -- it doesn't make a difference -- the script just won't execute > the function in the register_shutdown_function() -- > > The following script works great (see below) -- it seems that for some > reason its a TIMEOUT issue (bug). > > Running the script below, I will get the output of the print() function -- > as stated, from the command line. I understand that it wouldn't show up in > the browser. > > If I replace the "exit;" command with say a "while(1);" where the script > will loop indefinitely, the timeout, set by the set_time_limit(1) will stop > the script, but again -- register_shutdown_function() seems to "want to > work" as the function IS CALLED, but NEVER executed, and instead errors on > the 1st line in the FUNCTION -- always on a TIMEOUT. > > Run this script from your command line (ie. C:>php test.php) -- then change > the "set_time_limit(30)" to "set_time_limit(1)", and replace the > "exit" with > a "while(1)" -- run the script again, you'll see what I mean. > > And, if you still don't believe me, replace the print() in the function with > "error_log('Script Terminated', 3, 'errorlog.txt');" and see if > the > "errorlog.txt" file is ever created -- it isn't. > > <? > set_time_limit(30); > function clean_up() > { > print("Script Terminated"); > } > register_shutdown_function("clean_up"); > exit; > ?> > > If anyone can offer any reason why its doing this, please help -- thanks. > > Jason > > > > > "Cc Zona" <email@cczona.com> wrote in message > news:email-95A23B.19072218052002@pb1.pair.com... > > In article <20020519005201.26095.qmail@pb1.pair.com>, > > jason@thinkingman.org (Jason Caldwell) wrote: > > > > > Here's my code: > > > ---------------- > > > <? > > > set_time_limit(1); > > > function clean_up() > > > { > > > if(connection_status() & TIMEOUT) > > > print("Script timed out.\n"); > > > } > > > register_shutdown_function("clean_up"); > > > while(1); > > > ?> > > > > > > Here's the message I get: (I should get "Script timed out.") > > > > No, you shouldn't/wouldn't, because--as is noted in the docs > > <http://php.net/register-shutdown-function>--no more > > output ("print" is > > specifically mentioned as an example) can be sent to the browser at that > > stage. Try sending youself an email, or logging to a file instead. > > > > -- > > CC > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#98486) next »