Objects? Procedural? Pick your Pleasure!
The tidy PHP extension in PHP 5 has a incredibly flexible API which allows you to use procedural or object oriented syntax. In fact, you can even use both at the same time!

Procedural API
<?php
    /* Parse a file */
    $tidy1 = tidy_parse_file("myfile.html");
    
    /* Parse a string */
    $tidy2 = tidy_parse_string("<HTML><B>Hello!</B>");    

    /* Clean up the markup */
    tidy_clean_repair($tidy1);
    tidy_clean_repair($tidy2);
    
    /* Get the error buffer */
    $errors = tidy_get_error_buffer($tidy1);
    /* Get the output */
    $output = tidy_get_output($tidy2);
?>
Object Oriented API
<?php
    /* Create a new document instance */
    $tidy = new tidy_doc();
    
    /* Parse a remote URL via Streams */
    $tidy->parseFile("http://www.coggeshall.org/");

    /* Clean and repair the HTML document */
    $tidy->cleanRepair();

    /* Access the error buffer */
    $error_buf = $tidy->error_buf;
    
    /* Access the output by object overloading */
    echo $tidy;    
?>
    
Mix and Match
<?php
    /* Parse a new document */
    $tidy = tidy_parse_file("http://www.coggeshall.org/");
    
    /* Clean and repair the document */
    $tidy->clean_repair();

    /* Output the results; */
    echo $tidy;
?>