hey, thanks to arr1, and it is very useful for me, when I need to return to the user fast and then do something else.
When using the codes, it nearly drive me mad and I found another thing that may affect the codes:
Content-Encoding: gzip
This is because the zlib is on and the content will be compressed. But this will not output the buffer until all output is over.
So, it may need to send the header to prevent this problem.
now, the code becomes:
<?php
ob_end_clean();
header("Connection: close\r\n");
header("Content-Encoding: none\r\n");
ignore_user_abort(true); ob_start();
echo ('Text user will see');
$size = ob_get_length();
header("Content-Length: $size");
ob_end_flush(); flush(); ob_end_clean();
sleep(5);
echo('Text user will never see');
?>