output buffer

Hi,
I try to buffer a page. But it send output before my "echo $content" command. How can i disable this?
<?php
ob_start()
?>
<div>test</div>
<?php
$content=ob_get_flush();
echo $content; //I want to send output just this command....
?>

Open in new window

erenpasaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jausionsCommented:
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.
0
erenpasaAuthor Commented:
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?
0
jausionsCommented:
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.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
NoiSCommented:
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;
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.