<?php somesetupcode(); ob_start(); ?> <html> <body> html text </body> </html> <?php //This will assign everything that has been output since call to ob_start to your variable. $myHTML = ob_get_contents() ; ob_end_flush(); ?>
Short & to the point working PHP snipes.