Is it possible in PHP to grab the output of HTML code into a variable? Basically, I’m searching for a shorthand for this code:
<?php ob_start(); ?>
<div class="headSection">
<h1><?=$headline?></h1>
<p><?=$bottomline?></p>
</div>
<?php $contents = ob_get_contents(); ob_end_clean(); ?>
I want the HTML code to be saved in the $contents variable.
use PHP’s EOF string
Demo http://codepad.org/9OeUiJNJ