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

  • 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.

function w3Valid($url) {
	$snoopy = new Snoopy;

	$snoopy->fetchtext("" . $url . "&output=soap12");
	$validator_output = $snoopy->results;

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



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


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

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