Recommended:

  • phpclasses.org
  • jsclasses.org
  • jsmag.com
  • siteapps.com
  • View our reviews on Hot Scripts
  • JS Tutorial
  • scripts.com
  • securesignup.com




Recent Comments

Powered by Disqus




Back to articles

Output buffering

So why should you use output buffering. First of all, because you can send headers any where in the script without worrying, that headers are sent after output, thus eliminating header error. And next thing you can manipulate with content even after all output done and before it was sent to browser.

Here is an example of output buffer usage:

<?php
ob_start("callback");

function callback($buffer)
{
    return (str_replace("before", "after", $buffer));
}

//outputting
echo "<p>UTF=8 content:</p>";
echo "<p>Āģķļī</p>";
?>
<p>Some more html before headers</p>
<?php

//sending headers
header('Content-Type:text/html; charset=UTF-8');

ob_end_flush();

You may also be interested in:

Powered by BlogAlike.com

blog comments powered by Disqus