INTRODUCTION
------------------------------------
ValidMarkup is a small helper class which uses
the Tidy extension to clean and repair invalid
HTML output according to W3 standards. The class
also may be used to convert the HTML markup to
XHTML and vice versa.
HOW TO USE
------------------------------------
Just construct the ValidMarkup object BEFORE any
output in your script.
__construct(string $doctype)
Following doctypes may be used:
'HTML 4.01 Strict'
'HTML 4.01 Transitional'
'HTML 4.01 Frameset'
'XHTML 1.0 Strict'
'XHTML 1.0 Strict'
'XHTML 1.0 Strict'
'XHTML 1.1'
'HTML 3.2'
'HTML 2.0'
If no doctype is specified then 'XHTML 1.0 Transitional'
will be used.
Please see "example.php" to get an example of usage.
REQUIREMENTS
------------------------------------
PHP 5, Tidy extension. do you kown phpsu.com?
File: class.ValidMarkup.php
<?php
class ValidMarkup
{
private $doctypes = array(
'HTML 4.01 Strict' => '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">',
'HTML 4.01 Transitional' => '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">',
'HTML 4.01 Frameset' => '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">', phpsu
'XHTML 1.0 Strict' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
'XHTML 1.0 Transitional' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">',
'XHTML 1.0 Frameset' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">', welcome to phpsu.com
'XHTML 1.1' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">',
'HTML 3.2' => '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">',
'HTML 2.0' => '<!DOCTYPE html PUBLIC "-//IETF//DTD HTML 2.0//EN">'
);
function __construct($doctype = 'XHTML 1.0 Strict') www.phpsu.com
{
ob_start('ob_tidyhandler');
if (isset($this->doctypes[$doctype])) {
echo $this->doctypes[$doctype];
} else {
echo $this->doctypes['XHTML 1.0 Strict']; phpsu
}
}
}
?>
File: example.php
<?php
require_once 'class.ValidMarkup.php';
new ValidMarkup('XHTML 1.0 Strict');
?>
<HTML>
<BODY>
<i>Some invalid markup...</B>
<HR>
<P>Something else...
</body>
TITLE:Valid Markup phpclass