Graceful expiration of maximum execution time
Posted: Sun Nov 30, 2008 11:50 am
I have a database search script search.php, but on a sufficiently large database, some searches take forever, and I would like to limit the amount of time the script can run on the server before giving up.
I can put in a line like
set_time_limit(300);
but then the user who sees the script time out will receive an ugly black-and-white page that says
"Fatal error: Maximum execution time exceeded..."
This default error page can be confusing to the user, and it also gives away the server directory structure, which is, to say the least, not the preferred behavior.
How can I make an execution timeout more graceful? Can I replace or override the PHP default Fatal error page? Or is there some way to code the script such that I can achieve the same result as set_time_limit()?
I can put in a line like
set_time_limit(300);
but then the user who sees the script time out will receive an ugly black-and-white page that says
"Fatal error: Maximum execution time exceeded..."
This default error page can be confusing to the user, and it also gives away the server directory structure, which is, to say the least, not the preferred behavior.
How can I make an execution timeout more graceful? Can I replace or override the PHP default Fatal error page? Or is there some way to code the script such that I can achieve the same result as set_time_limit()?