Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 595775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:05:58+00:00 2026-05-13T16:05:58+00:00

Well, now that I’ve gotten a bit further into it, I realize that this

  • 0

Well, now that I’ve gotten a bit further into it, I realize that this is a stupid question, and wrong. Turns out that the author of the legacy code I maintain was hi-jacking the error log to a different file with a php_init statement. The hi-jacking occurred at the same time as the output buffering was turned on, making it appear as though output buffering was throwing away my error messages.

So, Mr. Moderator, feel free to delete this. Thanks to those who answered in good faith.


Given the following PHP script:

<?php 
error_log('test'); 

ob_start();

error_log('test2');

ob_end_flush();
?>

I get the following error log output:

[04-Feb-2010 11:30:38] test

Why is output buffering eating my error messages? How can I make it stop?

Alternately, is there another way to smuggle messages out of an output buffer, or is it simply a black hole?

(Using PHP 5.2.4-2ubuntu5.10)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T16:05:58+00:00Added an answer on May 13, 2026 at 4:05 pm

    Exceptions penetrate ob_start() shield

    If you want to stop PHP script execution, rather throw an Exception, which will penetrate the ob_start(), ob_end_flush() shield

    echo 'before output buffer';
    ob_start();
    throw new Exception('this will be seen');
    ob_end_flush();
    

    Consider creating a Logger class

    Don’t output directly with your method, rather use a class or a holder which incorporates the log (or error method in your case), eg:

    class Logger
    {
        private $_messages = array();
    
        public function __construct()
        {
            $this->_messages['errors'] = array();
            $this->_messages['debug'] = array();
        }
    
        public function error($msg)
        {
            $this->_messages['errors'][] = $msg;
        }
    
        public function debug($msg)
        {
            $this->_messages['debug'] = $msg;
        }
    
        public function getErrors()
        {
            return $this->_messages['errors'];
        }
    
    }
    
    $logger = new Logger();
    
    $logger->error('error1');
    
    ob_start();
    
    $logger->error('error2');
    
    ob_end_flush();
    
    print_r($logger->getErrors());
    

    this way you can rely on the holder object, it will not discard messages and get all errors, that you wanted to display

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Well, now that I've finally got my stupid ODBC stuff configured, I took a
Well, it appears that now that WCF has been out for a while, the
So I see that MVC 2 now supports [HttpPut] and [HttpDelete] as well as
Well, i've walking around this for a couples of days now... I think is
Well I have a string now that has the expression value to be evaluated..it
I'm building a interpreter/compiler for a school project (well now its turning into a
Now that Rails 3 is out, my favorite dev-mode plugin (rails-dev-boost) is broken. I'm
Now that we've ran out of int capacity on a PK column (which is
I have a multi-dimensional array right now that looks like this: function art_appreciation_feeds() {
I realize (having read other posts on SO as well) that it's bad design

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.