xref: /PHP-5.4/ext/tidy/examples/cleanhtml.php (revision 896ac689)
1<?php
2
3    /*
4     * cleanhtml.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 4.3.x, for tidy in PHP 5 see cleanhtml5.php
10     *
11     * By: John Coggeshall <john@php.net>
12     *
13     * Usage: php cleanhtml.php [filename]
14     *
15     */
16
17    if(!isset($_SERVER['argv'][1])) {
18      $data = file_get_contents("php://stdin");
19      tidy_parse_string($data);
20    } else {
21       tidy_parse_file($_SERVER['argv'][1]);
22    }
23
24    tidy_clean_repair();
25
26    if(tidy_warning_count() ||
27       tidy_error_count()) {
28
29        echo "\n\nThe following errors or warnings occurred:\n";
30        echo tidy_get_error_buffer();
31        echo "\n";
32    }
33
34    echo tidy_get_output();
35
36?>
37
38
39
40