You can try
while(true)
{
sleep(240); // sleep for 240 sec
echo " Hello World" ;
}
Or
$time = time();
while ( true ) {
/*
* Play Some Ball
*/
if ((time() - $time) >= 240) {
echo date("Y:m:d g:i:s"), PHP_EOL;
$time = time();
}
sleep(2);
}
Output Test with Time = 2 sec, Sleep = 1 sec
2012:10:14 12:50:56
2012:10:14 12:50:58
2012:10:14 12:51:00
2012:10:14 12:51:02
2012:10:14 12:51:04
2012:10:14 12:51:06
2012:10:14 12:51:08
2012:10:14 12:51:10
2012:10:14 12:51:12
2012:10:14 12:51:14
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…