Confusion over installation and use of PHP Tidy
Posted: Thu Jan 11, 2007 12:08 pm
I was using my own (primitive) function to tidy up my html code until a friend told me about php tidy, and output buffering. So I installed the beginners .exe from the PHP tidy website, and I used the following guide:
http://linuxformat.co.uk/wiki/index.php ... _extension
Anyway, I ended up with this code:
This works ok, but I have absolutely no idea how to change the settings. For example I would like to enable indentation, and change to xhtml instead of html.
So my questions are:
a) Is this the right way to go about it? Is there something more efficient / simpler? Or is it just plain wrong?
b) How do I change the settings with this or the better way of doing it? (Point me to a guide if relevant).
http://linuxformat.co.uk/wiki/index.php ... _extension
Anyway, I ended up with this code:
Code: Select all
ob_start();
echo "stuff to go in document";
$htmlContents = ob_get_contents();
ob_clean();
$tidy = new tidy('');
$tidy->parseString($htmlContents);
$tidy->cleanRepair();
echo $tidy;
ob_end_flush();So my questions are:
a) Is this the right way to go about it? Is there something more efficient / simpler? Or is it just plain wrong?
b) How do I change the settings with this or the better way of doing it? (Point me to a guide if relevant).