php

How to increase the execution time of a PHP script

In this tutorial, we are going to see how to increase the execution time of a PHP script. In PHP, the maximum execution time for each script is 30 seconds by default. You want to execute a large script that takes a long time to execute. To avoid the timeout, you need to increase the execution time in PHP. You can do this by editing the php.ini file or the PHP script.
 

Where is the php.ini file in a local server

– If you use WampServer, you will find the php.ini file in the following path:

  • On Windows : C:\wamp\bin\apache\apache2.4.9\bin\php.ini

– If you use Xampp, you will find the php.ini file in the following path:

  • On Windows : C:\xampp\php\php.ini
 

Method 1: Edit the php.ini file

Open the php.ini file and change the max_execution_time value to the desired duration (in seconds).

max_execution_time = 120 //120 seconds = 2 minutes

 

Method 2: Increase the execution time of the PHP script

Place the following line at the top of the PHP script.

ini_set('max_execution_time', 120); //120 seconds = 2 minutes

To make the execution infinite try the following code:

ini_set('​max_execution_time', 0); //0=NOLIMIT
mcqMCQPractice competitive and technical Multiple Choice Questions and Answers (MCQs) with simple and logical explanations to prepare for tests and interviews.Read More

Leave a Reply

Your email address will not be published. Required fields are marked *