Common tidy operations can be simplified into a single PHP function call which allows you to tidy a string or input file using a specified configuration...

tidy_repair_string($data [, $config_file]);

tidy_repair_file($data, [, $config_file [, $use_include_path]]);

Repairing http://www.coggeshall.org/
<?php
    
echo tidy_repair_file("http://www.coggeshall.org/""basic.tcfg");
?>
Repairing user POST data
<?php
    
if(!empty($_POST['data'])) {
        
$data tidy_repair_string($_POST['data']);
        echo 
htmlentities($data);
    }
?>