gpt4 book ai didi

php - 是否可以断开 http 客户端与 PHP 的连接?

转载 作者:可可西里 更新时间:2023-11-01 16:24:08 26 4
gpt4 key购买 nike

  1. 在 PHP 中是否可以(并且安全)关闭 http 连接而不返回任何 http 状态代码?我的服务器是 apache。
  2. 这会被记录到访问日志或错误日志中吗?

最佳答案

我使用以下代码:

/**
* Make the script run in the background
* return a message to the browser
* @param unknown_type $response
*/
function freeUserBrowser($response)
{
// let's free the user, but continue running the
// script in the background
ignore_user_abort(true);
header("Connection: close");
header("Content-Length: " . mb_strlen($response));
echo $response;
flush();

}

关于php - 是否可以断开 http 客户端与 PHP 的连接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3542439/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com