note 69957 deleted from function.set-time-limit by googleguy
| From: | googleguy@php.net | Date: | Thu, 17 Jan 2013 22:20:28 +0000 |
| Subject: | note 69957 deleted from function.set-time-limit by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-193189@lists.php.net to get a copy of this message | ||
Note Submitter:
----
After the error
Fatal error: Maximum execution time of [...] seconds exceeded [...]
has appeared, shut-down functions are still called (afterwards). So, by using
register_shutdown_function, you can save data in a session and offer the user a link to start the
script again. Then the script can go on with the Session-data.
Example: if you are analyzing a text-file, you can save your analyzed data in a session together
with the position of the filepointer (ftell) and start from that possition the next time the user
runs the script (fseek).
To determine whether the script was finished or aborted, you simply set a bool false at the
beginning and true at the end, and in the shutdown-function you check if it's still false.