Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/258.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php ob#U启动+;压缩文件输出_Php - Fatal编程技术网

Php ob#U启动+;压缩文件输出

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

我在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';
    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);
...
现在我的问题是:

  • 从MVC中取出
    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;