Tidy for PHP 4 and PHP 5

Tidy for PHP is an extension written for PHP 4.3+ (version 1.0) and then re-written for inclusion in the standard PHP 5.0 distribution (version 2.0+). It allows for the seamless integration of PHP scripts with the Tidy Utility which parses, validates, and repairs any HTML document.

"At first glance Tidy may seem like nothing more than a nice tool for the pedantic. At second glance I start to think Tidy may be the biggest new piece of functionality in PHP for a long time; one we're going to be thanking John for again and again."
-- Sitepoint.com

Getting Tidy for PHP

Depending on the version of PHP you are using (tidy is compatible with PHP 4.3 and higher) there are two different ways to aquire tidy.

If you are using PHP version 4.3+

If you are using PHP 4.3+, you'll need to download Tidy from the PECL Repository Right here and install it as a shared module for PHP.

If you are using PHP 5.0+

If you are using PHP 5.0+, the Tidy extension is bundled as part of the standard PHP distribution and you must only install the libtidy library and specify the --with-tidy option as part of your PHP configure parameters.

Important Note

Although the PECL repository claims that it is hosting a version of Tidy compatible with PHP 4.3 and higher, note that the version of Tidy bundled with PHP 5.0+ is not the same as the one found in the PECL repository. Tidy for PHP 5.0+ (extension version 2.0+) was completely rewritten to use the new PHP 5 architecture and supports many new features not found in the version of Tidy in the PECL repository for PHP 4.3+ (extension version 1.0+)