Fatal error: Maximum Execution Time of xx Second Exceeded in filepath.php

Use set_time_limit(timeInSecond or 0); in your script or max_execution_time in php config file(php.ini) for setting execution time of your script. If you want unlimited execution time then use 0 for second.

You may still be getting "execution time exceeded" error after setting long time for "execution time" in php.ini or your script through using set_time_limit(). This may be due to reason other than the script execution. This time only affect your PHP script running and not database connection time, file upload, and so on in your script. If your time is exceeded due to large file upload then you can use max_input_time.

Set_time_limit() only affect your current script, where you write this line.

You may need to check the Apache/ISS timeout as well. Default time there is 300 seconds.

Related:PHP Custom Error Handler
JavaScript Error Handling for Beginners
PHP Parse Errors

  • # 1 - by satyakaran

    I have found this comment on php.net very useful:

    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.

  • # 2 - by satyakaran

    I have found this comment on php.net very useful:After the errorFatal 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.

Comments are open for an year period. Please, write here on Facebook page.