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

mmo*_*nem 2 php apache http

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

Nir*_* O. 6

我使用以下代码:

/**
 * 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();

}
Run Code Online (Sandbox Code Playgroud)