我使用了以下代码来生成zip
// push to download the zip
header('Content-type: application/zip');
header('Content-Disposition: attachment; filename="'.$zip_name.'"');
readfile($zip_name);
这段代码运行得很好,但由于未知的原因,直到我尝试后才能运行
// push to download the zip
header('Content-type: application/zip');
header('Content-Disposition: attachment; filename="'.$zip_name.'"');
echo file_get_contents($zip_name);
我很想知道这两种情况下发生了什么。
发布于 2013-11-20 19:55:44
readfile会将文件直接读取到输出缓冲区中,file_get_contents会将文件加载到内存中,当您回显结果时,数据将有效地从内存复制到输出缓冲区中,使用的内存是Readfile的2倍。
https://stackoverflow.com/questions/20095175
复制相似问题