For dumping the output of a PHP page, I don't know of an easy way other than getting into the practice of using templates.
Templating means you will seperate the HTML code from your PHP code and have some PHP code to handle inserting PHP variables into the HTML code. It sounds tricky at first, but once you get the hang of it, it can be really handy.
In this scenerio, the template would be built and managed by a string. To dump everything to the browser, it might be as simple as just doing: echo $sTemplate; Instead of a browser, you want to dump it to a file. Not a problem: fputs($filepointer, $sTemplate); Here, the same exact code that was sent to the browser will get dumped to the file.
The only drawback is updating your pages to doing work like this.