1<?php 2 3 /* 4 * cleanhtml5.php 5 * 6 * A simple script to clean and repair HTML,XHTML,PHP,ASP,etc. documents 7 * if no file is provided, it reads from standard input. 8 * 9 * NOTE: Works only with tidy for PHP 5, for tidy in PHP 4.3.x see cleanhtml.php 10 * 11 * By: John Coggeshall <john@php.net> 12 * 13 * Usage: php cleanhtml5.php [filename] 14 * 15 */ 16 17 if(!isset($_SERVER['argv'][1])) { 18 $data = file_get_contents("php://stdin"); 19 $tidy = tidy_parse_string($data); 20 } else { 21 $tidy = tidy_parse_file($_SERVER['argv'][1]); 22 } 23 24 $tidy->cleanRepair(); 25 26 if(!empty($tidy->errorBuffer)) { 27 28 echo "\n\nThe following errors or warnings occurred:\n"; 29 echo "{$tidy->errorBuffer}\n"; 30 31 } 32 33 echo $tidy; 34 35?> 36