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 7883723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:36:34+00:00 2026-06-03T04:36:34+00:00

i have reviewed php manual about the ob_start() ob_end_clean() ob_end_flush(). And i have seen

  • 0

i have reviewed php manual about the ob_start() ob_end_clean() ob_end_flush(). And i have seen a different example about the subject, anyway i modified the example but i’m confused at this point. here is the script.

ob_start();
echo "Hello x, ";

ob_start();
echo "Hello y, ";

ob_start();
echo "Hello z, ";

ob_start();
echo "Hello World";
$ob_2 = ob_get_contents();
ob_end_clean();

echo "Galaxy";
$ob_1 = ob_get_contents();
ob_end_clean();

echo " this is OB_1 : ".$ob_1;
echo "<br>  and this is OB_2  : ".$ob_2;

And output of this script is:

Hello x, Hello y, this is OB_1 : Hello z, Galaxy

and this is OB_2 : Hello World

——————————————–

Why the output isn’t like that?

this is OB_1 : Hello x, Hello y, Hello z, Galaxy

and this is OB_2 : Hello World

And what is the point i have missed?

  • 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-06-03T04:36:35+00:00Added an answer on June 3, 2026 at 4:36 am

    Output buffers work like a stack. You create one buffer and echo “Hello x, ” into it, then you create another buffer and echo “Hello y ” into it, then you create a third buffer and echo “Hello z, ” into it. The “Hello World” goes into a fourth buffer, which is closed by the call to ob_end_clean(), so you’re back to the third one. When you call ob_get_contents() after echoing “Galaxy”, you’re getting the contents of that third buffer.

    If you call ob_get_contents() again at the end of this code, you’ll get the “Hello y, ” that’s in the second buffer. And if you ob_end_close() that and then ob_get_contents() again, you’ll get the “Hello x, ” from the first buffer.

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

Sidebar

Related Questions

I have reviewed numerous reports of this error but the solutions I have seen
I have reviewed a lot of information about these things, but can't understand what
I have reviewed several other posts about how to get the CLR to find
I have reviewed a few Struts 1 vs 2 questions on SO but none
Does solr saves indexes in files or memory? I have reviewed document but it
This question has been asked before, but none that I have reviewed give a
I have a website in PHP, Lighttpd. It uses also MySQL on Centos 5.
I have a classifieds website where users may sell/buy just about anything... My issue
Alright, probably not the best title, but meh. I have the following code inside
Thank you for submitting APPNAME_HERE. We have reviewed your application and have determined that

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.