saveHTMLExact(); } /** * Load HTML with a proper encoding fix/hack. * Borrowed from the link below. * * @link http://www.php.net/manual/en/domdocument.loadhtml.php * * @param string $html * @param string $encoding , default to UTF-8 * * @return bool */ public function loadHTML($html, $encoding = "UTF-8") { $html = mb_convert_encoding($html, 'HTML-ENTITIES', $encoding); if (!$this->debug) return @parent::loadHTML($html); // suppress warnings else return parent::loadHTML($html); } /** * Load partial HTML adding a doctype, and an empty head * * @param string $html * @param string $doctype , default to html (HTML5) * @param string $encoding , default to UTF-8 * * @return bool * @see loadHTML * */ public function loadPartialHTML($html, $doctype = 'html', $encoding = "UTF-8") { $html = '' . $html . ''; return self::loadHTML($html); } /** * Return HTML while stripping the annoying auto-added , , and doctype. * * @link http://php.net/manual/en/migration52.methods.php * * @return string */ public function saveHTMLExact() { $content = preg_replace(array("/^\<\!DOCTYPE.*?.*?/si", "!$!si"), "", $this->saveHTML()); return $content; } }