我想執行一個生成txt文件的exe文件,並在另一個腳本中檢查是否已創建txt文件。PHP - 等待文件存在
在xampp中,我只是將test.txt文件拖到下面的php腳本目錄中,但它似乎不能正常工作,如果我將text.txt添加到目錄並啓動腳本而不是啓動在添加之前,第二個回聲似乎永遠不會發生。
我該如何讓PHP等待文本文件存在然後繼續?
set_time_limit(0);
echo "Script began: " . date("d-m-Y h:i:s") . "<br>";
$status = file_exists("test.txt");
while($status != true) {
if ($status == true) {
echo "The file was found: " . date("d-m-Y h:i:s") . "<br>";
break;
}
}
這也不起作用:
set_time_limit(0);
echo "Script began: " . date("d-m-Y h:i:s") . "<br>";
while(!file_exists("test.txt")) {
if (file_exists("test.txt")) {
echo "The file was found: " . date("d-m-Y h:i:s") . "<br>";
break;
}
}
'$ status' __never__改變它的值。 –
*「雖然狀態不正確,如果狀態爲真...」 - - 這個嘗試的邏輯有很多錯誤。 – deceze
我曾試圖改變它是直接的,看到我的編輯,但它仍然無法正常工作,第二個回聲從來沒有發生過。 – zeddex