Home  >  Article  >  Backend Development  >  readfile下载文件加ob_clean作用

readfile下载文件加ob_clean作用

WBOY
WBOYOriginal
2016-06-23 13:50:30762browse

手册中readfile例子

$file = '12.jpg';if(file_exists($file)){		header('Content-Description: File Transfer');	header('Content-type: application/octet-stream');	header('Content-Disposition: attachment; filename=' . basename($file));	header('Content-Transfer-Encoding: binary');	header('Expires: 0');	header('Cache-control: must-revalidate');	header('Pragma: public');	header('Content-Length: ' . filesize($file));	ob_clean();	flush();	readfile($file);	exit();}

在这里加ob_clean和flush有什么作用?不加也能下载,加不加有什么区别


回复讨论(解决方案)

如果说 ob_clean(); 清除缓冲区,用的还有点道理的话
那么 flush(); 推出输出缓冲区,就没有道理了
因为无论如何,输出缓冲区中的内容都要被输出的

重新换了一本手册,原来手册的例子都是用户email给官方的
再照版主这么一说,手册不严谨也是正常的

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:请问这句是不是这个意思?Next article:数组取值