Never been to DZone Snippets before?

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

Simple w3c Validator (See related posts)

// 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 on this post

logankoester posts on Feb 16, 2007 at 14:34
Wow, this is really cool. Beautifully simple implementation. Thanks!

You need to create an account or log in to post comments to this site.


Click here to browse all 5147 code snippets

Related Posts