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

  • Home
  • SEARCH
  • 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 8859539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:05:21+00:00 2026-06-14T15:05:21+00:00

In PHP sometimes I see this: $html = <<<HTML <p>Hello world</p> HTML; Normally I

  • 0

In PHP sometimes I see this:

$html = <<<HTML
<p>Hello world</p>
HTML;

Normally I would have used ob_start() :

ob_start();
?>
<p>Hello world</p>
<?php
$html = ob_get_contents();
ob_clean();

Can you tell me what the difference between these two ways to write to the buffer and their advantages?

  • 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-14T15:05:23+00:00Added an answer on June 14, 2026 at 3:05 pm

    HEREDOC (<<<) is just another way to write a string data into a variable. The output buffer, on the other hand, will catch all output that takes place after ob_start() including (HTML) output of any warnings or errors you might have in the code before you call ob_get_contents();

    Usually, if you just need to format a string with HTML, just use HEREDOC or regular string notation. Output buffer is usually used if you need to catch output before you send any HTTP headers (for an example, if you’re using FirePHP to debug your application, you’ll need to use output buffering because FirePHP embeds the logging data in the HTTP headers).

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

Sidebar

Related Questions

Hoping someone can shed some light on this. I have a PHP program which
I have html structure like this: <div class='inside'> <div>429185</div> <div>492128</div> </div> Sometimes there is
I have a script scripty.php Sometimes this script gets called through the browser. Other
You can see it in action here: http://maenhaut.wordtgetest.be/index.php?a=nl&b=home sometimes it's alright, it shows as
I have a strange problem with php scripts - mysql_affected_rows() sometimes returns 0 for
* edit have fixed this code - see inline comments marked EDIT * I'm
Sometimes I see php comments with '@' in front of some lines. Like @Author
What I have noticed is that responses from AWS PHP SDK are sometimes a
When is it a good idea to use PHP_EOL ? I sometimes see this
Hit refresh several times and see sometimes I get null. This script loops through

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.