Back to Top

Include a file and store contents to variable using output buffer

Include a file and store contents to variable using output buffer

You guys must know about Output Buffering in PHP.Last time, my friend Bhumi has written an article about Output Buffering in PHP where she has showed you how to turn on and use Output Buffering in PHP.

So Here I am going to share this great feature of PHP.Let’s see the flashback .Output buffering allows you to have all output of PHP code stored into an internal buffer instead of immediately transmitted to the browser and output buffering also allows you to include a file and store contents (HTML and PHP) to a string variable.here is one step ahead with one more good example for output buffering

Here in above code I have included included-file.php file and displayed the whole content of the included file using output buffer.

That’s it. 🙂

Thanks for reading and feel free to share your thoughts, don’t Forget to Follow us on Twitter or Subscribe us to Get the Latest Updates.

Comments (2)

  1. Thanks, this was just what I needed!

Leave a Reply

Your email address will not be published. Required fields are marked *

Most Popular Posts

How to Create and Use Cookies in PHP

Posted on 1 year ago

Bhumi

The Readers’ Poll – March 2013

Posted on 5 years ago

Bhumi

How to create Cron jobs in WordPress?

Posted on 5 years ago

Bhumi

How to use CONST keyword in PHP

Posted on 6 years ago

Bhumi

Learn about the Docker and how it works

Posted on 1 year ago

Bhumi

Overview of ECMAScript 6 new Features

Updated 18 years ago

Bhumi

Getting started with Amazon Web Services

Updated 18 years ago

Bhumi

Facade implementation in Laravel

Updated 18 years ago

Bhumi

The Reader’s Poll – June 2015

Posted on 2 years ago

Bhumi

The Reader’s Poll – August 2014

Posted on 3 years ago

Bhumi

The Reader’s Poll – June 2014

Posted on 3 years ago

Bhumi

The Readers’ Poll – May 2014

Posted on 3 years ago

Bhumi

The Readers’ Poll – August 2013

Posted on 4 years ago

Bhumi