重复Php代码或脚本

时间:2013-02-23 12:10:34

标签: php ajax

简单问题,在Java中,有Timer类,或者是AlarmManager,甚至是一段时间(真实)循环来重复某些代码,我怎么能用Php代码实现,我想重复一些PHP代码/脚本,我有尝试过:

 while(true){
 ////Give me an Error , 'No Data Received from WebSite/Not Response
 }

 function Check(){
 ////Do Code
 Check()
 ////Syntax and Others Error , does Not Work
 }

 echo "<script>setTimeout('check()',10);"; ////does not Work too


 Additional Code :

 $q=mysql_query("SELECT message FROM $tbl_name WHERE pass='".$_SESSION['Logged']."'");
 while($row = mysql_fetch_array($q)){
 while(true)
 echo $row['message']; ///In French Language saying that the server closed the connection without sending any      Data, 
 Error : Erreur 324 (net::ERR_EMPTY_RESPONSE) : Le serveur a mis fin à la connexion sans envoyer de données.

 }

1 个答案:

答案 0 :(得分:0)

无法得到你想做的事,但是我理解你的问题 你可以使用类似的东西:

while ($something == true )
{
 //code to process here and keeps repeating until condition is met.
 myFunction();

}

function myFunction(){
//code of your function
}