How to increase execution time of a PHP script ? Last Updated : 12 Sep, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report Increasing the execution time of a PHP script means extending the maximum time a script is allowed to run before the server terminates it. This is often necessary for resource-intensive tasks, like data processing or large file uploads, to prevent timeouts.Here we have some common approaches to increase the execution time of a PHP script :Table of ContentUsing ini_set() Using set_time_limit() FunctionUsing ini_set()The ini_set() approach in PHP allows you to increase the script's execution time by dynamically setting the max_execution_time configuration. This method applies only to the current script, enabling you to extend runtime without altering global server settings.Syntax:ini_set('setting_name', value);Example 1: In this example we set the max_execution_time to 60 seconds, allowing the script to run longer if needed, then outputs the text "GFG Learning portal" to the webpage. PHP <?php ini_set('max_execution_time', 60); // Increase execution time limit to 60 seconds echo "GFG Learning portal" ?> Output:GFG Learning portal Using set_time_limit() FunctionThe set_time_limit() function in PHP sets the maximum execution time for a script in seconds. Passing a value resets the timer, allowing longer runtime. It overrides the default limit, preventing premature script termination for time-consuming tasks.Syntax: set_time_limit(60);Example: In this example we increases the maximum execution time to 60 seconds using set_time_limit(60), ensuring the script won't timeout early, and then outputs "GFG Learning portal" to the browser. PHP <?php // Increase execution time limit to 60 seconds set_time_limit(60); // Output message echo "GFG Learning portal"; ?> Output:GFG Learning portal Comment More infoAdvertise with us Next Article How to check the Execution Time of Python script ? A akhilvasabhaktula03 Follow Improve Article Tags : Web Technologies PHP PHP-Questions Similar Reads How to Measure Script Execution Time in PHP? Measuring the script execution time in PHP is the time required to execute the PHP script. To calculate script execution time use clock time rather than the CPU execution time. Measuring script execution time is useful to check and improve the execution time for better application performance.Measur 2 min read How to terminate execution of a script in PHP ? In this article, we are going to discuss how to terminate the execution of a PHP script. In PHP, a coder can terminate the execution of a script by specifying a method/function called the exit() method in a script. Even if the exit() function is called, the shutdown functions and object destructors 2 min read How to check the Execution Time of Python script ? Checking the execution time of a python script helps you measure how long a piece of code takes to run. This is useful for analyzing performance, especially when working with large data or complex algorithms.Let's explore different ways to check execution time of python.Using timeit moduletimeit mod 3 min read How is it possible to set an infinite execution time for PHP script ? Yes, it is possible to set an infinite execution time for the PHP Script. We can do it by adding the set_time_limit() function at the beginning of the PHP script. The set_time_limit() function takes only one parameter that is int value which is in seconds and it returns a boolean value. If the scrip 2 min read How to Start and Stop a Timer in PHP ? You can start and stop a timer in PHP using the microtime() function in PHP. The microtime() function is an inbuilt function in PHP which is used to return the current Unix timestamp with microseconds. In this article, you will learn the uses of the microtime() function. Syntax: microtime( $get_as_f 2 min read How to Set Time Delay in PHP ? To set a time delay in PHP, you have several approaches depending on your requirements. The time delay is useful for various purposes like creating a pause in script execution or scheduling tasks. These are the following different approaches: Table of Content Using sleep() FunctionUsing usleep() Fun 2 min read Like