我有一个可以运行很长时间的PHP脚本.我已通过使用set_time_limit()函数将执行时间限制设置为5分钟.我想问一下是否可以将脚本设置为在达到超时限制时调用函数?例如iPhone SDK中JavaScript中的页面卸载脚本或NSViewController中的viewDidUnload函数?
I have a PHP script that will run for a long time. I have set the execution time limit to 5 minutes by using set_time_limit() function. I would like to ask whether I can set the script to call a function when timeout limit is reached? like the page unload script in JavaScript or viewDidUnload function in NSViewController, in iPhone SDK ?
推荐答案您可以使用 register_shutdown_function()在执行完成后注册一个回调,即调用该回调.您还应该看看连接处理.
You can use register_shutdown_function() to register a callback, that is called, when the execution finishes. You should also have a look at connection handling.
更多推荐
在PHP中页面超时之前调用一个函数
发布评论