output buffer

Posted on 2008-11-05
Last Modified: 2012-05-05
I try to buffer a page. But it send output before my "echo $content" command. How can i disable this?






echo $content; //I want to send output just this command....


Open in new window

Question by:erenpasa
    LVL 11

    Expert Comment

    Is  that the only files that's loaded? Look for blank lines in other files if that's not the case.

    Finally, check for UTF BOM (some hiding characters at the very beginning of a file that identifies it a UTF-encoded). You may want to look for the UTF-encoding related settings in your text editor. PHP doesn't handle these bits very well, and they may be the ones causing problem.

    Author Comment

    i've looked my file but it's seem normal.can you upload a small file for me?
    is my code run at your system?
    LVL 11

    Accepted Solution

    If it's a UTF BOM issue, yes, your file will look normal. As stated, the BOM is hidden in common text editor, so it looks like there is nothing at the first line. So you really need to look at your editor's settings to see if UTF BOM is enabled or not. If it is, you want to turn it off, and save your file making sure it doesn't use UTF BOM marking.

    That's one of the possible problem.

    Another reason might be that you use ob_get_flush() which returns the buffer's content AND output it to the client. Look at ob_get_clean() (PHP5) or ob_get_contents() / ob_end_clean() (PHP4) otherwise.
    LVL 11

    Assisted Solution

    Whe you call ob_get_flush(); The buffer is outputted;
    Instead use ob_get_clean(); if you need to cleand the buffer after get the content;
    or ob_get_contents(); if you need the buffer intact;

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
    Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now