hmdw
hmdw

Reputation: 23

Set maximum execution time in PHP

I tried to increase the max execution time in my php.ini file. It doesn't work, however. Considering the fact that I' ve got a large file (containing 300 pages) I have to download using PHPEXCEL, I did the following in my php. ini file:

max_execution_time = 999999999     
max_input_time = 9999999    
max_input_nesting_level = 64  
memory_limit = 128M      

Is there anyone who knows what to do in this situation?

Upvotes: 2

Views: 13500

Answers (3)

Pedro Lobito
Pedro Lobito

Reputation: 98921

On some of my php scripts that take long time to run I always use the following code at the top:

set_time_limit(0);
ignore_user_abort(1);

Explanation:

set_time_limit(0);

We're telling php the script can run for unlimited time.

ignore_user_abort(1);

We're telling php to continue running the script even if the user disconnects.
i.e.: closing the browser or disconnect from a SSH session.

Upvotes: 0

Thibault Henry
Thibault Henry

Reputation: 841

You can use 0 :

max_execution_time = 0     

That will disabled the limitation. Don't forget to restart apache after.

You can also user the PHP version :

<?php set_time_limit(0); ?>

Upvotes: 4

John Bell
John Bell

Reputation: 2350

If you don't want a limit, then you can use this:

set_time_limit(0);

But only if safe_mode is off, otherwise you can use ini_set:

ini_set('max_execution_time', 300); // 300 Seconds

Thanks.

Upvotes: 0

Related Questions