php8.5
Home/ Manual/ reference / tidy/ Tidy example

Tidy example

Examples

Tidy example

This simple example shows basic Tidy usage.

Basic Tidy usage

php
<?php
ob_start();
?>
<html>a html document</html>
<?php
$html = ob_get_clean();

// Specify configuration
$config = array(
           'indent'         => true,
           'output-xhtml'   => true,
           'wrap'           => 200);

// Tidy
$tidy = new tidy;
$tidy->parseString($html, $config, 'utf8');
$tidy->cleanRepair();

// Output
echo $tidy;
?>

Source: reference/tidy/examples.xml · from the official PHP manual (php/doc-en)