ob_start();// Your original PHP here... not the one you've edited$somevar = ob_get_contents();ob_end_clean();