在PHP中页面超时之前调用一个函数 [英] Call a function before the page is timeout in PHP

查看:79
本文介绍了在PHP中页面超时之前调用一个函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个可以运行很长时间的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中页面超时之前调用一个函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆