示例#1
0
                } elseif (!in_array($cleanedXML[strlen($cleanedXML) - 1], array("\n", $this->indentBy[strlen($this->indentBy) - 1])) || !in_array($xml[$char], array("\r", "\n", "\t", " "))) {
                    $cleanedXML .= $xml[$char];
                }
            }
        }
        $this->cleanedHash = md5($xml);
        $this->cleanedXML = $xml;
        // Return!
        return $cleanedXML;
    }
    /**
     * Prints $indentation $indentLevel times
     * @return string indentstring
     * @param int $indentLevel
     * @param string $indentation
     */
    private function getIndentation($indentLevel, $indentation)
    {
        $out = '';
        for ($i = 0; $i < $indentLevel; $i++) {
            $out .= $indentation;
        }
        return $out;
    }
}
$lezaz->listen('output.filter', function ($output, $filtered) {
    $output = empty($filtered) ? $output : $filtered;
    $clean_html = new CleanOutput();
    //return $output;
    return $clean_html->clean($output);
});
<?php

include "cleanmyhtml.class.php";
//If you want OB, put this on the top and see the bottom line:
ob_start();
//Constuction of object
$cleaning_object = new CleanOutput();
//Get HTML
$google_HTML = file_get_contents("http://www.google.com");
//Clean and print
$cleaning_object->process($google_HTML);
$cleaning_object->show();
//Reset object for new use
$cleaning_object->reset();
/*      Configuring output       */
$cleaning_object->trace = TRUE;
//This enables trace-lines
$cleaning_object->indent = "\t";
//This changes the indent-level to be a tab
//Clean, print and reset with new configuration
$cleaning_object->process($google_HTML);
$cleaning_object->show();
$cleaning_object->reset();
/*      Cleaning XML       */
$rss_feed = file_get_contents("http://www.xml.com/cs/xml/query/q/19");
$cleaning_object->setXML();
$cleaning_object->show();
//Continuation of OB
$o = $cleaning_object->ob_clean(ob_get_contents());
ob_end_clean();
echo $o;
 /**
  * Return clean or normal html code
  *
  * @return string
  */
 public static function clean_code($html)
 {
     if (Config::get('cms::settings.clear_engine')) {
         $clean = new CleanOutput();
         $clean->process($html);
         $clean->show();
         $clean->reset();
     } else {
         return $html;
     }
 }