I’m trying to see the evolution of the variable X, so that then I will be able to see the increment of the variable with slow speed.
When I try this code in a local host using the software XAMPP, the PHP code is working correctly, so that I’m able to see a new value of X every new second.
When I try the same code in a web hosting (FreeWHA) The webpage completely freezes until the while loop “is going”, And once the cycle is ended the page will load all the output printed all at once.
this below is the very basic code:
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<?php
$x=0;
while($x<100) { //print first 100 values
$x = $x + 1;
echo "x = ". $x. "</br>";
ob_flush();
flush();
usleep(1000000); //1 seconds = 1000000
}
?>
</body>
</html>
What should I do to make the web hosting page that I’m using to print the output of the variable X gradually?
How can I perform this task?