我想知道通过 Ajax 调用 PHP 脚本的生命周期。假设服务器上有一个长时间运行(即 30 秒)的 PHP 脚本,并且该页面是通过 Ajax 加载的。在脚本完成之前,用户关闭浏览器。脚本是否继续运行直至完成,是否终止,或者这是服务器本身的功能(我正在运行 Apache fwiw)。感谢您的帮助。
最佳答案
这可能令人感兴趣:ignore_user_abort()
ignore_user_abort — Set whether a client disconnect should abort script execution
但是请注意
PHP will not detect that the user has aborted the connection until an attempt is made to send information to the client.
关于PHP、Ajax 和请求的生命周期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3002058/