睡眠功能启动两次

问题描述 投票:0回答:0

我的DB中有31行,我想用2秒的时间间隔加载它们。但当睡眠功能上线60秒后,主功能重复,$count重置。

我的代码。

    $count = 0; 
    $files_count = count($files);
        foreach($files as $file) {
            $count++;
            $bot_file_name = $file['bot_file_name'];
            $bot_file_tg_id = $file['bot_file_tg_id'];
            $bot_file_format = $file['bot_file_format'];
            if ($bot_file_format == "pdf") {
                // do something
            } else if ($bot_file_format == "video") {
                // do something
            } else if ($bot_file_format == "audio") {
                // do something
            }
            if ($count == $files_count) {
                break;
            }
            sleep(2);
        }

我不明白这里有什么问题,php max_execution_time是120。

php sleep
© www.soinside.com 2019 - 2024. All rights reserved.