2

为什么需要这个函数的最后一行才能完成这项工作?我不明白这里发生了什么。不过它确实有效。

function close_connection() {
    // if we're using sessions this stops them from hanging on other requests
    session_write_close();
    // get the content length from the buffer (the whole point of the buffer)
    header('Content-Length: 0');
    // close the connection
    header('Connection: close');
    // flush the buffers to the screen
    flush();

    // connection closing doesn't work without this. I don't know why
    echo ' ';
}
4

1 回答 1

1

每当第一个字节输出到浏览器时,都会发送标头。
您也可以尝试使用ob_end_flush();

于 2013-07-17T22:33:44.330 回答