Is there anything i am doing wrong in the following code.
Ob_start should buffer the output right and it should not print it before you flush. But it is doing that
<?php
echo "Hello World!";
ob_start();
for ($i=0; $i < 100; $i++ ){
echo "I am fine </br>";
}
?>
I am getting the output "i am fine"
It's flushed when the script ends, so of course you will still get the output, it just won't be sent while the script is still running.
You should do something with the buffer at the end of your script.
E.g. get the contents with ob_get_contents()
and clear it with ob_end_clean()
, otherwise it is flushed at the end.