skip to Main Content

ob_flush(); is not working on nginx server. but works on Apache localhost.
Hello,
I have been trying to make following code work.

PHP:

ob_flush();
flush();

following code works perfectly fine on my local host with PHP7x.

PHP:

header('Content-Type: text/html; charset=UTF-8');
if (ob_get_level() == 0) ob_start();
for ($i = 0; $i < 10; $i++) {
    echo '|'.$i;
    ob_flush();
    flush();
    usleep(1000000); // 1s
}

on my localhost it appends one number and shows on screen every second.
but this is not working on Plesk server with PHP7x and PHP8x

I’ve added following lines in PHP Settings for my domain

output_buffering = on

But flush() is not working.

I’m the root user (administrator) of my VPS.. I can access to PHP.INI.. I can make changes into that too. But doesn’t seem it is working. Whenever I hit the URL .. it holds for 10seconds and then shows the output all at once.

Can somebody please suggest me what things should I make to make it work.


Please signup or login to give your own answer.
Back To Top
Search