HTML validation

ok. ok. ok. Wait for it.

I wrote a function that lets you validate your php pages using the w3.org validatorserver side in only 6 lines of php.



function w3saysPageIsValid($url)
{
if (strpos($_SERVER['REMOTE_HOST'], "w3.org"))
return true; //just abort!!! infinite loops are bad!!!
$dom = new DOMDocument;
$w3url = "http://validator.w3.org/check?uri=" . urlencode($url);
$dom->loadHTMLFile($w3url);
$xpath = new DOMXPath($dom);
return $xpath->query('//h2[@class="valid"]')->length > 0;
}

I rule.