On using ini_set(‘max_execution_time’, 0);

Posted on

On using ini_set(‘max_execution_time’, 0); – Here in this article, we will share some of the most common and frequently asked about PHP problem in programming with detailed answers and code samples. There’s nothing quite so frustrating as being faced with PHP errors and being unable to figure out what is preventing your website from functioning as it should like php and mysql . If you have an existing PHP-based website or application that is experiencing performance issues, let’s get thinking about On using ini_set(‘max_execution_time’, 0);.

How do I use ini_set('max_execution_time', 0);?

Question 1: Do I place it at the top of the .PHP file or in a function that takes a long time to do something?

Question 2: Does this setting last forever after being set? Or does it return back to its original 300sec or whatever default value after the function stops running?

Solution :

You can place it anywhere, but that setting won’t take effect until it runs. So if you put it at the top, then the script will never timeout. If you put it down below on the function that can take awhile, then you may get a timeout above if the script takes a long time to get to where you called it.

When you use ini_set() that option stays in effect for the entire execution of the script.

2: It only last for that page that loaded. after that its done.

1: It should be placed at the start of the code, but it can be placed anywhere.

Answer 1: before you execute the long-running code

Answer 2: it lasts until the php process ends

Leave a Reply

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