Is there any way to call a function 10 seconds after the page load in PHP. (Not using HTML.)
If I interpret your question as "My page takes a long time to generate, now can I call a PHP function every 10 seconds while it generates" then there are several ways you can approach this...
$nexttick=time()+10;
$active=true;
while ($active)
{
if (time()>=$nexttick)
{
my_tick_function();
$nexttick=time()+10;
}
//now do some useful processing
$active=do_some_work();
}
It's possible to use a technique like this to implement a progress meter for long running operations, by having your "tick" function output some javascript to update the HTML representing a progress meter.
Alternatively, if you have the Process Control support enabled in your build of PHP, you might be able to use pcntl_alarm to call a signal handler after a certain amount of time has elapsed.
You can use the declare construct along with register_tick_function to have the PHP engine call your function every x 'ticks'. From the manual:
A tick is an event that occurs for every N low-level tickable statements executed by the parser within the declare block. The value for N is specified using ticks=N within the declare blocks's directive section.