How to Resolve the Fatal error: Maximum Execution time of 30 seconds exceeded in PHP

Errors are an inseparable part of any working process.

The development is not an exception, either. But it is essential to find proper resolutions to the errors caused by different factors.

In case you have encountered the fatal error: maximum execution time of 30 seconds exceeded in PHP, it means that the actions to do by the Apache web server to carry out your task took a long time. Hence, it was suspended by the limit provided by PHP ini configuration.

To solve the problem, you can go on with changing the setting of a time limit with the function set time limit. There, you can give the maximum execution time in seconds as a parameter.

Below, we will provide you with two handy solutions to the problem.

Watch a course Learn object oriented PHP

Solution A

In the framework of the first solution, you should take several easy steps. Let’s check them out.

Step 1

First of all, you should open the php.ini file.

Step 2

The next step is changing the value of “max_execution_time” to a bigger value.

Step 3

The final step is restarting the server.

Solution B

Now, let’s see an alternative solution. This option is more recommended that the first one.

All you need to do is adding set_time_limit(600) inside the code. The input parameter is the maximum execution time. The meaning of 0 is unlimited.

However, you should be careful, as, in the case of an endless job, you may hang your server. So, we recommend you not to set the value too high.