Back to index

php5  5.3.10
cleanhtml.php
Go to the documentation of this file.
00001 <?php
00002 
00003     /*
00004      * cleanhtml.php
00005      *
00006      * A simple script to clean and repair HTML,XHTML,PHP,ASP,etc. documents
00007      * if no file is provided, it reads from standard input.
00008      *
00009      * NOTE: Works only with tidy for PHP 4.3.x, for tidy in PHP 5 see cleanhtml5.php
00010      *
00011      * By: John Coggeshall <john@php.net>
00012      *
00013      * Usage: php cleanhtml.php [filename]
00014      *
00015      */
00016     
00017     if(!isset($_SERVER['argv'][1])) {
00018       $data = file_get_contents("php://stdin");
00019       tidy_parse_string($data);
00020     } else {
00021        tidy_parse_file($_SERVER['argv'][1]);
00022     }
00023     
00024     tidy_clean_repair();
00025     
00026     if(tidy_warning_count() ||
00027        tidy_error_count()) {
00028         
00029         echo "\n\nThe following errors or warnings occured:\n";
00030         echo tidy_get_error_buffer();
00031         echo "\n";
00032     }
00033     
00034     echo tidy_get_output();
00035     
00036 ?>
00037     
00038         
00039      
00040