Tell me how to execute the code in the script a specified number of times after a certain period of time. For example, execute $this->method(); 3 times in 60 seconds?

    3 answers 3

    JavaScript: setInterval+ajax .

    • But still using php? - co11ter
    • In php intervals you can not specify. But if you make a request to php on AJAX in 3 seconds, it will turn out (probably) what you need is atnartur
    • I found: Php has sleep (); - co11ter
    • Then your script will load 3 minutes :) - atnartur
     for($i=0; $i<=2; $i++) { $this->method(); sleep(600); } 
    • one
      sleep(60) probably? As correctly noted @atnartur - the script will load 3 minutes. Still, I will look in the direction of JS setInterval. - co11ter


    • Considered this option. Only as I understood it, you can execute scripts on a schedule, but I need to execute the method from the script several times on the server of the hoster. I do not have access to the shells. - co11ter