- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
readfile 的 PHP 文档有一个如何下载文件的示例:
<?php
$file = 'monkey.gif';
if (file_exists($file)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);
exit;
}
?>
它使用 ob_clean 删除可能在输出缓冲区中的内容。
但是我读过的帖子 ( http://heap.tumblr.com/post/119127049/a-note-about-phps-output-buffer-and-readfile ) 指出对于大文件应该使用 ob_end_clean 而不是 ob_clean。
我的问题是:使用 ob_clean 而不是 ob_end_clean 有什么用?如果 ob_end_clean 像 ob_clean 一样工作并且避免了问题,为什么所有文档都没有显示使用 ob_end_clean?
最佳答案
ob_clean()
刷新缓冲区,但保持输出缓冲处于事件状态。这意味着您的 readfile()
输出也将被缓冲。
ob_end_clean()
刷新缓冲区,并完全关闭缓冲,允许 readfile()
直接转储到浏览器。
关于php - 从 ob_clean 更改为 ob_end_clean?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21262271/
ob_get_contents(); ob_end_clean(); ob_start() 使用ob_start()把输出那同输出到缓冲区,而不是到浏览器。 然后用ob_get_contents得
readfile 的 PHP 文档有一个如何下载文件的示例: 它使用 ob_clean 删除可能在输出缓冲区中的内容。 但是我读过的帖子 ( http://heap.tumblr.com/post/
这两个PHP有什么区别吗? ob_start(); //code... $pageContent = ob_get_contents(); ob_end_clean(); someFunction($
我已经阅读了有关 ob_start() ob_end_clean() ob_end_flush() 的 php 手册。我已经看到了关于该主题的不同示例,无论如何我修改了该示例,但此时我很困惑。这是脚本
我是一名优秀的程序员,十分优秀!