php code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
majidali
Forum Newbie
Posts: 17
Joined: Thu Mar 11, 2010 3:33 am

php code

Post by majidali »

can ne one explain me the of ob_start .is it useful to maintain sessions?
thanx in advance.
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: php code

Post by Eran »

ob_start() starts output buffering. This means any output after it will not be sent and instead will be stored in a buffer. There are many uses to this, such as controlling when output will be sent and manipulating it before outputting it.

Since sessions cannot be sent after output has been sent, using output buffering can be helpful to make sure headers are indeed sent before any output.

You can find much more information in the manual -
http://php.net/manual/en/function.ob-start.php
wanger220
Forum Newbie
Posts: 19
Joined: Tue Feb 02, 2010 8:44 pm

Re: php code

Post by wanger220 »

Something I had been wondering ... does ob save HTML tags? I have a lengthy php/mysql script formatted into a <table> - at some point I need to output the HTML code for use in an XML feed.

Can this be done with something like echo htmlentities(ob_get_clean($str)) ?
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: php code

Post by Eran »

output buffering saves all output after it is called to the buffer. So yes, that would include HTML tags
Post Reply