Created
March 11, 2016 01:35
-
-
Save kfriend/e8ffd86d6f489c901789 to your computer and use it in GitHub Desktop.
PHP: Send response and continue processing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Buffer all upcoming output... | |
ob_start(); | |
// Send your response. | |
echo "Testing response"; | |
// Get the size of the output. | |
$size = ob_get_length(); | |
// Disable compression (in case content length is compressed). | |
header("Content-Encoding: none"); | |
// Set the content length of the response. | |
header("Content-Length: {$size}"); | |
// Close the connection. | |
header("Connection: close"); | |
// Flush all output. | |
ob_end_flush(); | |
ob_flush(); | |
flush(); | |
// Close current session (if it exists). | |
if (session_id()) { | |
session_write_close(); | |
} | |
sleep(30); | |
file_put_contents('/tmp/foo', 'testing'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thank you very much, i`m old in github but this is my first comment in all github, Because you saved me so much time,
thanks again <3 <3 <3