Home > Software engineering >  How can I make a counter from 1 to 100 with PHP?
How can I make a counter from 1 to 100 with PHP?

Time:05-01

Hello friends, how can I add a counter that will count from 1 to 100 and then count from 1 to 100 again after a few minutes? It will be with PHP.

CodePudding user response:

Here is a way to count until 100 in PHP but please make sure you choose your tags right, your question is currently marked as a javascript question

I know it is related to javascript but your problem doesn't include even a piece of javascript

<?php
while (1){ 
    for ($x = 0; $x <= 100; $x  ) {
        echo "The number is: $x <br>";
        sleep(1);
    }
}
?>

CodePudding user response:

I would strongly suggest CRON JOBS for periodic script execution.

But it looks like some school or maybe even for fun task. So the Answer from @Ramsey above should be sufficient.

(dont forget to kill the infinite process created by while (1))

  • Related