Cannot use output buffering in output buffering display handlers

前端 未结 3 1435
长发绾君心
长发绾君心 2021-01-17 17:24

I\'ve reinstalled Apache, and switched from PHP 5.3 to 5.6. Everything works, except I get this error, when calling ob_start():

Cannot use outpu         


        
相关标签:
3条回答
  • 2021-01-17 18:02

    Probably you are using a buffering function in output buffering callback which isn't possible as mentioned in php ob_start output_callback documentation. If not it should be the output-handler you used, check your php.ini and try to set it's value to "none" if possible.

    0 讨论(0)
  • 2021-01-17 18:10

    You're trying to start a output buffer inside a buffer callback. If you use this code, it will generate that error. But if you remove the ob_start() from the callback function it's OK.

    <?php
    error_reporting(-1);
    
    function callback($buffer){
        //you can't call ob_start here
        ob_start();
        return (str_replace("apples", "oranges", $buffer));
    }
    
    ob_start("callback");
    
    ?>
    <html>
    <body>
    <p>It's like comparing apples to oranges.</p>
    </body>
    </html>
    <?php
    ob_end_flush();
    
    0 讨论(0)
  • 2021-01-17 18:14

    maybe this sample code can help you:

    ob_start();
    echo "test";
    $content = ob_get_contents();
    ob_end_clean();
    var_dump($content);
    
    0 讨论(0)
提交回复
热议问题