DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Simple W3c Validator

02.10.2007
| 7035 views |
  • submit to reddit
        // This function will return either a true or false (boolean) value, whether a certain site contains valid code based on w3 standards. Requires the Snoopy PHP class.
// Could be used in many situations where a simple "is valid" or "is not valid" result is required.

<?php
function w3Valid($url) {
	require("Snoopy.class.php");
	$snoopy = new Snoopy;

	$snoopy->fetchtext("http://validator.w3.org/check?uri=" . $url . "&output=soap12");
	$validator_output = $snoopy->results;

	if(preg_match("/false/", $validator_output)) {
		return false;
	} else {
		return true;
	}
}

?>
    

Comments

Snippets Manager replied on Tue, 2007/06/05 - 11:43am

nh

Logan Koester replied on Sun, 2006/09/10 - 9:05pm

Wow, this is really cool. Beautifully simple implementation. Thanks!