How to Increase Your PHP Maximum Execution Time?

 

An important aspect to remember about PHP programs is that the maximum time to execute a script is usually set to thirty or sixty seconds. However, the time limit varies from one hosting company to another. Programs that involve sending mail to many recipients or some heavy export or import of files can cause the user to get errors if the maximum time limit exceeds.

You might need to increase the limit for specific scripts your website uses. For instance, migration plugins in WordPress, depending on your website's size, usually require a longer run time.

Thirty seconds is the default setting, and you can increase that value. Keep in mind that the matter is in seconds, so 2 minutes would be 120, 3 minutes would be 180, and so on. You can check your plugin, script, or theme's documentation to find the correct value. You can use the phpinfo() function to verify the current value of the max_execution_time directive and other directives.

If you're wondering how to set PHP maximum execution time on cPanel, we will do a quick step-by-step guideline for new learners who want to do this. The first thing you need to do once you log in to your cPanel account using your username and password, or you can also log in via HostezaClient Area.

The next thing you want to do is find the PHP Selector button. After you've selected this button, you will go to the Options section for the php.ini values and scroll down to max_execution_time.

840

For Unlimited, you set the value to 0. Once you have made the change, make sure you do a left-click anywhere outside the text input or dropdown box. If you've successfully followed the steps mentioned above, you will see a green box with a message confirming that the change you've made has been applied.

 
 
Measuring Script Execution Time

The time required to execute the PHP script is the script execution time in PHP. Rather than the CPU execution time, use clock time to calculate script execution time. Knowing the clock time after and before script execution will help to know the script execution time.

Use the microtime() function at the script's beginning and end. It was then used the formula (End_time – Start_time). Time returns in seconds with the microtime() function. Execution time depends on the processor, and it is not fixed.

Now you know everything there is to know about increasing the maximum execution time of a script in cPanel. For any further assistance, make sure you contact us so we can help you!

Cette réponse était-elle pertinente? 3 Utilisateurs l'ont trouvée utile (0 Votes)