Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

max execution time error handling

I have one script that sometimes gives Max execution times reached error. This is normal, not this a problem. The problem is that in this case I would write specific error message.
How do i do this?

like image 583
turbod Avatar asked Jul 01 '10 08:07

turbod


People also ask

What should max execution time?

Maximum execution time (max_execution_time) is a time limit on how long a PHP script can run. It is a way hosting providers can limit the use and abuse of server resources, especially for shared hosting. The actual default value depends on the hosting, but it-s usually set to 30 (i.e. 30 seconds).

How do you calculate max execution time?

Using PHP max_execution_time directive You can control the amount of time PHP allows scripts to run by changing the max_execution_time directive in your php. ini file. To verify the current value of the max_execution_time directive and other directives, you can use the phpinfo() function.


1 Answers

function say_goodbye() {
   if (connection_aborted()) {
      //  Perform some action if user has aborted the transaction
   } elseif (connection_status() == CONNECTION_TIMEOUT) {
      //  perform some other action if the connection has timed out
   } else {
      //  any normal completion actions
   }
}

register_shutdown_function("say_goodbye")

You can also pass parameters to the shutdown function

like image 171
Mark Baker Avatar answered Sep 23 '22 23:09

Mark Baker