Try to plan your extension before you start writing your code. A good way to do this is to write a sample PHP script that illustrates how your extension is going to be accessed from a PHP script.

HTML Tidy Sample Extension
<?php
$tidy 
tidy_create();
tidy_set_option($tidy"show-body-only""yes");
@
tidy_parse_string($tidy"<b>foo <i>bar</b></i>");
tidy_clean_and_repair($tidy);
ob_start();
tidy_output($tidy);
$clean ob_get_contents();
ob_end_clean();
echo 
htmlspecialchars($clean);
?>
HTML Tidy Sample Extension (OO for PHP4)
<?php
$tidy 
= new tidy();
$tidy->set_option("show-body-only""yes");
$tidy->parse_string("<b>foo <i>bar</b></i>");
$tidy->clean_and_repair();
$tidy->output();
?>
HTML Tidy Sample Extension (OO for PHP5)
<?php
$tidy 
= new tidy();
$tidy->show_body_only "yes";
$tidy->parse_string("<b>foo <i>bar</b></i>");
$tidy->clean_and_repair();
$tidy->output();
?>