Php ob#U启动+;压缩文件输出
我在MVC模式下工作 我有Php ob#U启动+;压缩文件输出,php,Php,我在MVC模式下工作 我有index.php作为基本文件,控制器位于/controllers/目录中。例如,如果转到/stream/xIEjeEJWqs,将执行/controllers/streamcontroller.php index.php是这样开始的,它缩小了将要发送到浏览器的输出: <?php function replace_tabs_newlines($content) { require_once 'includes/min/lib/Minify/HTML.php
index.php
作为基本文件,控制器位于/controllers/
目录中。例如,如果转到/stream/xIEjeEJWqs
,将执行/controllers/streamcontroller.php
index.php
是这样开始的,它缩小了将要发送到浏览器的输出:
<?php
function replace_tabs_newlines($content)
{
require_once 'includes/min/lib/Minify/HTML.php';
require_once 'includes/min/lib/Minify/CSS_MODIFIED.php';
require_once 'includes/min/lib/JSMin.php';
$content = Minify_HTML::minify($content, array(
'cssMinifier' => array('Minify_CSS', 'minify'),
'jsMinifier' => array('JSMin', 'minify')
));
return $content;
}
ob_start('replace_tabs_newlines');
ob_implicit_flush(0);
...
现在我的问题是:
streamcontroller.php
,您有什么建议?例如,在index.php
旁边有streamer.php
index.php
的replace\u tabs\u newlines($content)
函数中添加check functionality,以检查浏览器是否指向streamcontroller.php
且不执行缩小作业ob_start()
的回调在即将输出某些内容时被检查?ie:在streamcontroller.php
中的readfile()之前
在
readfile
之前添加一个如何在readfile
之前添加一个如何是的,它工作得很好。像这样:ob_end_clean();标题('Content-type:image/png');标题('Content-Length:'.filesize($file));readfile($file);退出代码>。。。只是我不确定这是否是一个好的方法,请告诉我是否有任何缺点,我很乐意接受你的回答。感谢you@tmpmember我认为这种方法没有缺点是的,它很有效。像这样:ob_end_clean();标题('Content-type:image/png');标题('Content-Length:'.filesize($file));readfile($file);退出代码>。。。只是我不确定这是否是一个好的方法,请告诉我是否有任何缺点,我很乐意接受你的回答。感谢you@tmpmember我认为这种方法没有缺点
<html>
<head>
<title>
Minifies..
</title>
case "png":
header('Content-type:image/png');
header('Content-Length: ' . filesize($file));
readfile($file);
exit;
break;