Here's something odd, I though this would output a page and show part by part, until all is loaded (similar to how Wordpress update/reinstall process works):
<html>
<body>
<?php
for( $i=0; $i<100; $i++)
{
echo 'HELLO';
}
sleep(10);
echo '<p></p>';
for( $i=0; $i<100; $i++)
{
echo 'THERE';
}
sleep(10);
echo '<p></p>';
for( $i=0; $i<100; $i++)
{
echo 'HOW ';
}
sleep(10);
echo '<p></p>';
for( $i=0; $i<100; $i++)
{
echo 'ARE U';
}
sleep(10);
echo '<p></p>';
Oddly enough it waits for the entire page, then shows it. What variables/configuration affect this behavior?
I dont know how you think php works, but it is only server side and you are expecting partial updates in client side. PHP does not work like that.
When you call that php script, php interpreter begin to execute it, putting the output into temporary location, then with the sleep function, php interpreter waits until milliseconds are reached, then continue executing, concatenating the output in the temp location, and go on... after all script execution is done, php sends the whole output to the client.
If you need partial updates on a page, you need to enter in the world of async calls and ajax.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With