There is a function in php, let's say:
function pop($num) { //..... }
How can I run it after a certain time interval? Is there an analog to the js function setTimeout in php?
There is a function in php, let's say:
function pop($num) { //..... }
How can I run it after a certain time interval? Is there an analog to the js function setTimeout in php?
It will not work for you as in JS. You have to use cron here
can not. There is no setTimeout counterpart in PHP.
I would do it like this.
I assigned a variable to the function date (i) , indicated the format, and then compared it with a condition (for example, minutes), if it is true, the function would be executed.
PS At the same time the page should reload every time.
Therefore...
... In general, it is better to use JS.
PHP has such a great function as sleep
.
here you need to use the header header
<?php header('Refresh:1'); echo date('dmY H:m:s'); ?>
The type of watch is obtained, but the whole page will be updated.
Source: https://ru.stackoverflow.com/questions/90476/
All Articles