Page 1 of 1
php code
Posted: Sat May 15, 2010 7:50 am
by majidali
can ne one explain me the of ob_start .is it useful to maintain sessions?
thanx in advance.
Re: php code
Posted: Sat May 15, 2010 9:08 am
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
Re: php code
Posted: Mon May 17, 2010 11:48 am
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)) ?
Re: php code
Posted: Thu May 20, 2010 12:03 pm
by Eran
output buffering saves all output after it is called to the buffer. So yes, that would include HTML tags