This may be a dumb question, but do you make unit tests for the HTML output of your PHP functions/scripts?
I try to keep my HTML and my PHP separate - i.e. HTML includes
You can use PHPUnit. It has Output testing.
http://www.phpunit.de/manual/3.0/en/testcase-extensions.html