I'm working on a php project . A class file which has function index which has a while loop that runs indefinitely sleeping every 3 sec and printing some information . so I wrote a php script which creates an object of tht class file and runs the class function using call_user_func_array function . But the script crashes every 2.30 hours (approximately) with the error "maximum execution time of 300 secs exceeded " .
so tried a different script which doesnt have a class file and have a while loop sleeping every 3 sec and printing the same information . But this script does not crash at all .. Can some one pls help me on what call_user_func_array does ??
main.php
<?php
set_time_limit(300);
require("/project/DCM/dcm.php");
$foo = new Dcm();
call_user_func_array(array($foo, "index"),array());
?>
class Dcm
{
public function wakeup_device()
{
for($i=0;$i<1000;$i++)
{
print("bfr request :".date("Y-m-d H:i:s:u")."\n");
print("Time ..$i");
print("after request :".date("Y-m-d H:i:s:u")."\n");
}
}
public function index()
{
while(1)
{
$this->wakeup_device();
sleep(3);
}
}
}
test.php
<?php
set_time_limit(300);
while(1)
{
$i=0;
for($i=0;$i<1000;$i++)
print("\n".date("Y-m-d H:i:s")."test ..$i\n");
sleep(3);
}
?>