Answer the question
In order to leave comments, you need to log in
Is there a txt file in php, if not, then we are waiting for it to appear?
Do not judge strictly. There is a txt file in php, if not, then we are waiting for it to appear? How to implement it in php?
$file = 'exchange_id_1.txt';
if(file_exists($file))
{
//Файл есть, обработали.Вывели
}
else
{
//Файла нет, ждем пока появится.
}
Answer the question
In order to leave comments, you need to log in
function processing_file($file_path)
{
if ( ! file_exists($file_path)) {
// Засыпаем на 5 секунд
sleep(5);
// рекурсивно вызываем функцию
processing_file($file_path);
}
// Обработка файла
}
while(!file_exists($file)) {
sleep(5); // файла нет, ждем 5 сек, повторяем заново
}
// файл появился, работаем.
Through timeout
function est_li_file($vashfile, $timeout) {
ini_set('default_socket_timeout', $timeout);
stream_set_timeout($timeout);
$vashfile = fopen($vashfile, 'r');
if($vashfile) {
fclose($vashfile);
ваш код
}else{
ваш код когда отсутствует
}
}
How should he appear? Do you need to create a script? Someone creates files by hand? Magic ala "vzhuh and the file appeared"?
file_put_contents() & fopen()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question