Skip to main content

Capturing echo Output into a Variable in PHP

Hi Guys,
This is cool stuff. Did you ever know that you can capture the echo output in your PHP code? Since the echo function is void (which means returns nothing) you might have thought that is not possible on this Earth right? I thought that too. But guess what, this as easy as 4 lines.. :O

Code:
   ob_start();
   echo 'Hello World!';
   $hello_str   = ob_get_contents();
   ob_end_clean();

That will store your "Hello World!" string into the $hello_str variable without actually echoing it on the browser. Give it a try fellas! ;-)

Cheers.

Comments

Popular posts from this blog

Ruby, Easy Development.

Hi guys, Everything under this article ( here i have mentioned very few things ) is absolutely true and exercised..... because I am new to this language and I learned it very fast that I learned other languages and there are more to cover too.... If you are having basic theoretical knowledge on 'Object Oriented' concepts you are most welcome to Ruby..., You won't take more than 2 days to learn basic of the Ruby language. You will realise it once you are there...... Have fun with Ruby....., Ruby; Ruby is a Ob ject Oriented Pro gramming language which is created by Yukihiro Matsumoto (Matz) . He has often said that he is “ trying to make Ruby natural, not simple, ” in a way that mirrors life. It was first released on 1995. Since that growth of the Ruby language was unstoppable. This marvelous, handy and artful language is absolutely free, not only free of charge but its free to use. You will feel like flying on the free sky when you develop applications with Ruby. In

BandLuxe Dongle is not Working on Fedora Linux?

Isn't your 3G USB Dongle/Modem is not working on Fedora Linux? Don't worry there is a simple solution for this. But remember BandLuxe is supported by Fedora 13 onwards. Issue is sometimes it can't identify the proper mode for your dongle. Your dongle has 2 interfaces. CD-ROM 3G Modem On a windows operating system these modes are switched easily with the shipped driver. Early days on Fedora 13 it perfectly identified my USB dongle as a 3G Modem. Right after I plugged in the device the NetworkManger Applet started showing the 3G network. For some reason this functionality isn't there now. The usb_modswitch  (for those who don't know about this. This is the tool that do the mode switch for your device. Apparently this works as the driver) is still there though, and all the configurations are seems to be ok. Somehow its not doing what its expected to do anymore. So I had to find a solution for this. Finally I've found one. The trick is done using sd

Fedora Guide

Most people think that getting things done on Fedora Linux is very difficult. But it is not the case. People doesn't want to change. How bad is that. But I say that configuration and most other things that you want to change on your OS is very easy on Unix base systems. I know that, because I'm using it... :-) OK it's time to get exited now..... Try the following link.... Fedora Guide