I asked a similar question , and you can check out some of them there.
In general, I would recommend either running the HTML code on a neat host, or writing a short script to test through W3C remotely. Personally, I don't like the neat option, because it reformatts your code, and I hate how it puts <p> tags on every line.
Here is a link to tidy and here is a link to various W3C verification tools .
Keep in mind that HTML validation does not work with server-side code; It only works after evaluating your PHP. This means that you will need to run your code through the host PHP interpreter, and then "connect" it to either the tidy utility or the remote verification service. This command will look something like this:
$ php myscript.php | tidy #options go here
Personally, I ultimately decided to give up the headache and simply visualize the page, copy the source and verify it using direct input in the W3C verification utility. There are so many times that you still need to check the page, and there was more to automating it than it was worth.
Good luck.
Thomas
source share