使用php创建超过1.5k的文件

使用php创建超过1.5k的文件,php,file,Php,File,所以我想运行这个脚本,一次创建大约1.5k个文件。但没有这么大的成功,原因是它只创建了5-10个文件 原因是脚本运行的时间不够长,无法创建每个文件。因为我猜文件生成是异步的 我怎么能做这样的事 我的代码如下 try { $this->tmp_file_name = 'article' . md5(time()); //-- open file $file = fopen($this->tmp_file_name, 'w');

所以我想运行这个脚本,一次创建大约1.5k个文件。但没有这么大的成功,原因是它只创建了5-10个文件

原因是脚本运行的时间不够长,无法创建每个文件。因为我猜文件生成是异步的

我怎么能做这样的事

我的代码如下

try {
        $this->tmp_file_name = 'article' . md5(time());
        //-- open file
        $file = fopen($this->tmp_file_name, 'w');
        if (!$file) {
            throw new \ErrorException('Cannot create ' . $this->tmp_file_name . ' file!');
        }

        //-- write file
        $fwrite_result = fwrite($file, json_encode($data));
        if (!$fwrite_result) {
            throw new \ErrorException('Cannot create ' . $this->tmp_file_name . ' file!');
        }

        fclose($file);

        return true;
    } catch (\Exception $ex) {
        return false;
    }

现在这个方法被调用了超过1.5k次

调用它多少次,它是否返回false?否,它不会返回false,因为如果调用它,它将引发异常,并且浏览器中不会显示任何异常。这可能有助于设置:set_time_limit(0);在你的纸条顶端,那些设置允许你的脚本永远运行。你试过了,仍然不起作用对于那些1.5K的迭代,什么是
$this->tmp\u file\u name
,是否返回false?否,不返回,因为如果返回,则会引发异常,并且浏览器中不会显示任何异常。这可能有助于设置:set_time_limit(0);在你的脚本顶部,这些设置允许你的脚本永远运行。你试过了,仍然不起作用对于那些1.5K的迭代,什么是
$this->tmp\u file\u name