在 PHP 中,我编写了如下代码
//Example Code
foreach($arrayitem as $arr) //$arrayitem is having some array data
{
$fp=fopen($arr.'.xls','w');
for(condition)
{
//here i'm getting full content of an webpage(huge data) and some regexp to match data
preg_match(regexp,getContent of an URL,$output);
fputs($fp,$output);
}
fclose($fp);
}
这里的想法是创建一个文件并将数据写入$output
变量,然后创建第二个文件并将 $output 写入该文件,依此类推,直到
$arrayitem
get 完成中的所有值。
- 但我观察到的是第二个文件和其他连续文件是在第一个文件完成之前创建的
- 并且文件大小正在缓慢增加(刷新文件大小正在改变)
这怎么可能?这里实际发生了什么?通常只有在第一个文件完成后才应该创建下一个文件,对吗?