Methods ob_start and ob_flush don't work, why?

You also need to check the PHP settings

some installs default to 4096, some default to off

output_buffering = Off
output_buffering = 4096

agreed with George but do check the above settings


Make sure that your output buffering doesn't start automatically. Run:

print ob_get_level ();

before ob_start (); if will will see something else then 0 you've got the answer.


Hey man I was also got stuck in this problem and finally got the correct solution here it is for you

you have to add content type for your page you can do that by two ways 1. using html tag

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

Ex.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Wp Migration</title>
</head>
<body>
<?php 
for($i=0;$i<70;$i++)
{
echo 'printing...<br>';
ob_flush();
flush();
sleep(3);
}
?>
</body>
</html>
  1. using php header function

    <?php header( 'Content-type: text/html; charset=utf-8' ); ?>

Ex.

<?php 
header( 'Content-type: text/html; charset=utf-8' );
for($i=0;$i<70;$i++)
{
echo 'printing...<br>';
ob_flush();
flush();
sleep(3);
}
?>

All the best