0

When you register a function in register_shutdown_function how can you check for the error max execution time limit?

register_shutdown_function(function(){
    if(something)){
        // max execution time exceeded
    }
});
clarkk
  • 27,151
  • 72
  • 200
  • 340
  • ..as well as this duplicate: http://stackoverflow.com/questions/9310375/detect-when-running-time-is-near-max-execution-time – h2ooooooo Mar 18 '16 at 09:13

2 Answers2

0

You can set a variable in the start of script to get time script execution started and if you reach here register_shutdown_function(function(){ calculate difference between that time and current time if it's greater than the time you have for execution(default 30 sec.) it's max execution time limit error

itzmukeshy7
  • 2,669
  • 1
  • 21
  • 29
0

You just have to get last error with error_get_last() and check if it says that maximum execution time exceeded.

loler
  • 2,594
  • 1
  • 20
  • 30