note 129058 added to function.ob-flush
| From: | thecichos at gmail dot com | Date: | Tue, 21 Nov 2023 12:12:33 +0000 |
| Subject: | note 129058 added to function.ob-flush | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-221012@lists.php.net to get a copy of this message | ||
The output buffer seems to work best when the server is returning a code 206 and setting the
output_buffering lower temporarily to let it fill up
This tells the browser to wait for additional content
for example:
// Set the header to 206
header("HTTP/1.1 206 Partial Content; Content-Type: text/html; charset=utf-8");
// Flush the current outputbuffer
flush();
ob_flush();
ob_end_flush();
// Create a new output buffer
ob_start();
// Save the current output buffer size
$tempBuffering = ini_get("output_buffering");
// Set a new, much smaller buffer size
ini_set("output_buffering", 256);
// Do some buffering
!!! All your amazing code goes here !!!
// Fill the buffer with something if needed
echo str_pad(" ", (int)ini_get("output_buffering"), " ");
flush();
ob_flush();
// Revert the buffer size
ini_set("output_buffering", $tempBuffering);
----
Server IP: 45.112.84.4
Probable Submitter: 45.91.157.134 (proxied: 80.209.65.4)
----
Manual Page -- https://php.net/manual/en/function.ob-flush.php
Edit -- https://main.php.net/note/edit/129058
Del: integrated -- https://main.php.net/note/delete/129058/integrated
Del: useless -- https://main.php.net/note/delete/129058/useless
Del: bad code -- https://main.php.net/note/delete/129058/bad+code
Del: spam -- https://main.php.net/note/delete/129058/spam
Del: non-english -- https://main.php.net/note/delete/129058/non-english
Del: in docs -- https://main.php.net/note/delete/129058/in+docs
Del: other reasons-- https://main.php.net/note/delete/129058
Reject -- https://main.php.net/note/reject/129058
Search -- https://main.php.net/manage/user-notes.php