简体   繁体   中英

PHP close HTTP connection then continue processing?

Why is the last line of this function required to make this work? I don't understand what's going on here. It does work though.

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 ' ';
}

Headers are sent whenever the first byte is output to the browser.
You could also try to use ob_end_flush();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM