News Feed
Sections




News Archive
feed this:

Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Juozas Kaziukenas' Blog:
Prevent scripts from being killed
March 26, 2009 @ 13:18:26

Juozas Kaziukenas has a helpful tip you can use on those long-running scripts to keep going - the set_time_limit function.

I have some very time consuming scripts running through CRON - some nice web scrapping jobs. They are not processing-intense, but rather slow because of slow websites. All these jobs are really hard to divide in to separate scripts (another article), so one script should have no limits to run for hours. However, web servers don't like it by default.

He show how you can use the set_time_limit function to free your script of the timeout limitation (which can be a good and bad thing) or having your script output something, like a "processing" message, as it runs through the loop to keep the timeout away. You can also use the ignore_user_abort function to continue the process even if the user hits the stop button or otherwise closes the request.

0 comments voice your opinion now!
timeout user settimelimit ignoreuserabort processing


Paul Reinheimer's Blog:
When does a user abort?
October 03, 2007 @ 07:52:00

Paul Reinheimer recently discovered something interesting about how PHP handles users aborts (hitting the stop button in the browser, closing it) and the steps the language follows after that.

I was under the impression that when the user hit stop, the script stopped. Which is: bad, and wrong. PHP doesn't detect that the user has terminated the connection, it has no clue, it obligingly continues processing along, until it attempts to send information to the user.

The "ignore_user_abort" configuration option in the php.ini controls some of this, allowing for you to specify whether or not the script should go ahead and finish out even after PHP has discovered that the client has been disconnected. There's also a function that allows you to specify the same thing on a script-by-script basis (in both PHP4 and PHP5).

0 comments voice your opinion now!
user abort script phpini ignoreuserabort disconnect user abort script phpini ignoreuserabort disconnect



Community Events





Don't see your event here?
Let us know!


install developer list community series framework refactor introduction interview opinion podcast language release unittest testing laravel configure code threedevsandamaybe symfony2

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework