gpt4 book ai didi

PHP-等待文件存在

转载 作者:行者123 更新时间:2023-12-01 08:23:53 25 4
gpt4 key购买 nike

我想执行一个生成txt文件的exe文件,然后在另一个脚本中执行,然后检查是否已创建txt文件。

在xampp中,我只是将test.txt文件拖到以下php脚本dir中,但它似乎无法正常工作,如果我将text.txt添加到dir中并启动脚本,而不是在添加脚本之前也未启动那么第二 echo 似乎永远不会发生。

如何使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;
}
}

最佳答案

这应该很好

set_time_limit(0);

echo "Script began: " . date("d-m-Y h:i:s") . "<br>";

do {
if (file_exists("test.txt")) {
echo "The file was found: " . date("d-m-Y h:i:s") . "<br>";
break;
}
} while(true);

关于PHP-等待文件存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43027624/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com