On using ini_set('max_execution_time', 0);

All we need is an easy explanation of the problem, so here it is.

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?

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

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.

Method 2

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.

Method 3

Answer 1: before you execute the long-running code

Answer 2: it lasts until the php process ends

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply