Just for curiosity: Is there any advantage by using this?
<?php
ob_start();
?>
<html>
<!--Page contents-->
</html>
<?php
$html = ob_get_contents();
ob_end_clean();
echo $html;
?>
Just for curiosity: Is there any advantage by using this?
<?php
ob_start();
?>
<html>
<!--Page contents-->
</html>
<?php
$html = ob_get_contents();
ob_end_clean();
echo $html;
?>
There is none.
However, ob_start
can take a callback parameter which is extremely useful. I use it to append /t=FILEMTIME
to all static files, ensuring that all files are updated immediately when I upload them.
Also, you can use header
, session_start
, setcookie
and other functions that operate on headers at any time, instead of having to worry whether you've started sending output yet or not.
Finally, those last lines are a very expensive no-op. The output buffer is processed at the end of the script anyway.