Detect when running time is near max_execution_time

前端 未结 1 1594
梦如初夏
梦如初夏 2021-01-24 08:49

I want my script to detect when it\'s near the maximum execution time, so it can stop and update the database.

I know phpMyAdmin does something like this when importing

相关标签:
1条回答
  • 2021-01-24 09:08

    register_shutdown_function() can work... all instantiated object sare still present, but you need to make sure they're available in the scope of your shutdown callback function, which means you need to register the shutdown function after setting up your db connection, and pass the db connection as an argument to the callback function. The shutdown function is also called when the script terminates normally, or via a connection abort, so you need to ensure that you're not duplicating work that has already been done

    0 讨论(0)
提交回复
热议问题