I need to find a PHP based HTML (as in WC3-Like) Validator that can look for invalid HTML or XHTML. I've searched Google a little, but was curious if anyone has used one they particularly liked.
I have the HTML in a string:
$html = "<html><head>.....</body></html>";
And I would like to be able to test the page, and have it return the errors. (Not echo/print anything)
I've seen:
-http://www.bermi.org/xhtml_validator
-http://twineproject.sourceforge.net/doc/phphtml.html
The background for this is that I'd like to have a function/class that I run on every page, check if the file has been modified since the last access date (or something similar to that), and if it hasn't, run the validator so I am immediately notified of invalid HTML while coding.
There's no need to reinvent the wheel on this one. There's already a PEAR library that interfaces with the W3C HTML Validator API. They're willing to do the work for you, so why not let them? :)
While it isn't strictly PHP, (it is a executable) one i really like is w3c's HTML tidy. it will show what is wrong with the HTML, and fix it if you want it to. It also beautifies HTML so it doesn't look like a mess. runs from the command line and is easy to integrate into php.
check it out. http://www.w3.org/People/Raggett/tidy/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With