I want to ask that how can i use php function again and again after some time automatically just like setInterval in Javascript. We set the time and it is on its job until t
since the asynchronous concept of web development has to do with effecting the changes on a web page without reloading the page, we must not always run to the bays of Ajax when ever we need such effects on our web pages, PHP can simply do the job of going to the database @ sleep seconds to retrieve some sets of data for our usage especially for chat application purposes. See the below codes:
function setInterval ( $func, $seconds )
{
$seconds = (int)$seconds;
$_func = $func;
while ( true )
{
$_func;
sleep($seconds);
}
}
Now, let's say we have a function get_msg() that goes to the database to download some sets of information, if we must do that repeatedly without the repeated usage of button calls, then, see the usage of the setInterval function written above with the get_msg function.
setInterval ( get_msg(), 5 );