Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


output buffer

Posted on 2008-11-05
Medium Priority
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
  • 2
LVL 11

Expert Comment

ID: 22887622
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

ID: 22888802
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

jausions earned 750 total points
ID: 22888926
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

NoiS earned 750 total points
ID: 22889403
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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…
Suggested Courses

578 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