HTML Validator for PHP

The HTML Validator for PHP is a PHP class filter designed to submit a HTML interfaces of dynamic web applications to the W3C HTML Markup Validation Service and display the results in an HTML table. It is designed to be super easy to use.


To use this class, just include the file at the top of the PHP script producing the HTML output (before any HTML has been written), as follows:

<?php include("/path/to/HTMLValidator.class.php");
$v = new HTMLValidator();

And that's it--no other configurationis necessary.

Configuration options

method signature default value description
setFileExtension .validate.html the file extension given to the temporary file written to disk
setWorkDir [directory where PHP script was run] the directory where static files should be written to disk
setWorkDirUrl [web path to directory where PHP script was run] the web server URL for the workDir; used to show the validation service where to access the static HTML files

To configure the display of the output, you can use CSS. The results are displayed in a div with an 'id' of 'htmlvalidator', and you can use CSS selectors to modify the display. For example, to set a 1 pixel border on the table and its cells, you could do this:

#htmlvalidator table {
border:1px solid #ccc;

#htmlvalidator td {
border:1px solid #ccc;