PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Web Services » Services_W3C_HTMLValidator » Manual

This package provides a programmable interface to the W3's HTML Validation service at http://validator.w3.org/. With this package you can use PHP to obtain usable validation results for HTML. The package utilizes the SOAP 1.2 output format of validator to populate validation result objects with true | false as well as any errors and warning messages. See the examples included with the package for usage.

Introduction

Introduction – Introduction to Services_W3C_HTMLValidator

Overview

The package provides an object oriented interface to communicate with W3C's HTML validator by using their XML-based output interface. See the examples page for information on how to use this package to get validation results.

Setup

Installation

The Services_W3C_HTMLValidator package can be installed using the PEAR installer command pear install Services_W3C_HTMLValidator. If the installation fails due to missing dependencies, one either needs to install them manually or can make the installer fetch all dependencies automatically: pear install -a Services_W3C_HTMLValidator.

Examples

Examples – Using Services_W3C_HTMLValidator

Getting results from the HTML Validator

The following examples demonstrate how to get validation results from an instance of the W3C HTML Validator.

Validate by URI

This is a simple example which shows how to validate a URI and return whether the page is valid or not.

<?php
require_once 'Services/W3C/HTMLValidator.php';

$v = new Services_W3C_HTMLValidator();
$u = 'http://www.unl.edu/';
$r = $v->validate($u);

if ($r->isValid()) {
    echo $u.' is valid!';
} else {
    echo $u.' is NOT valid!';
}
?>