I have in my index.php file
<?php ob_start(); echo '<html> <head> <style> body {background-color: black; color: white} </style> </head> <body> <h2 id="greeting">Wait for page load</h2> </body> </html>'; ob_flush(); flush(); sleep(100); echo '<script>document.getElementByID("greeting").innerHTML = "Page loaded!";</script>'; ob_flush(); flush(); ?> I thought it will send the HTML content to the client and they will see a "Wait for page load" text because it is flushed out, but on my website the webpage is just a blank white screen until the PHP code has finished executing (after 100 seconds) then everything on the page displays at once.
I have tried adding
echo str_repeat("<!--AAAAAAAAAAAA-->", 100); after each echo as well to make sure it starts sending blocks of data to the browser but that didn't work either.
Is there a way for me to display the HTML content from the php file before the php code finishes executing?
Thanks!
EDIT: Everyone is telling me to use ob_start(); ob_flush(); and flush(); but I have used it in the code above already?
sleep(100);hence it display after 100 seconds