Home » » ob_start

ob_start

Written By 1 on Sunday, September 30, 2012 | 7:06 PM

bool ob_start ([ callable $output_callback [, int $chunk_size = 0 [, bool $erase = true ]]] )

Turn on output buffering

This function will turn output buffering on. While output buffering is active no output is sent from the script (other than headers), instead the output is stored in an internal buffer.


<?php

function callback($buffer)
{
  
// replace all the apples with oranges
  
return (str_replace("apples""oranges"$buffer));
}

ob_start("callback");

?>
<html>
<body>
<p>It's like comparing apples to oranges.</p>
</body>
</html>
<?php

ob_end_flush
();

?>

5.4.0 A chunk size of 1 now results in chunks of 1 byte being sent to the output buffer. 4.3.2 This function was changed to return FALSE in case the passed output_callback can not be executed. 4.2.0 Added the erase parameter.


Beginner PHP Tutorial - 64 - ob_start

0 Comment:

Post a Comment