Home >Backend Development >PHP Tutorial >readfile下载文件添ob_clean作用

readfile下载文件添ob_clean作用

WBOY
WBOYOriginal
2016-06-13 12:05:391116browse

readfile下载文件加ob_clean作用
手册中readfile例子

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

在这里加ob_clean和flush有什么作用?不加也能下载,加不加有什么区别
------解决方案--------------------
如果说 ob_clean(); 清除缓冲区,用的还有点道理的话
那么 flush(); 推出输出缓冲区,就没有道理了
因为无论如何,输出缓冲区中的内容都要被输出的

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