2013-02-23 45 views
0

簡單的問題,在Java中,有Timer類,或AlarmManager,甚至一段時間(true)循環來重複某些代碼,我如何實現與PHP代碼,我想重複一些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. 

} 
+0

是在'周圍的代碼'標籤,並且您的網站是否支持PHP。你也無法在其內部無限調用該函數。 – 2013-02-23 12:14:16

+0

如果您想重複使用'for'循環,請使用'for'循環 – 2013-02-23 12:16:09

+0

PHP並不適合無限循環。 http://stackoverflow.com/questions/1765733/when-are-infinite-loops-are-useful-in-php – Chris 2013-02-23 12:19:30

回答

0

不能得到你想要做什麼,但作爲我明白你的問題,你 可以使用類似:

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

} 

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

$東西必須永遠是真的,這就像是(真)至極我試過沒有運氣,我編輯我的帖子及添加更多信息 – Nikita 2013-02-23 12:38:17

+0

沒有任何人得到答案?? – Nikita 2013-02-23 15:41:17