Adding $doc->saveHTML(false); will not work and it will return an error because it expects a node, not a bool.
The solution I used:
return preg_replace('/^<!DOCTYPE.+?>/', '', str_replace( array('<html>', '</html>', '<body>', '</body>'), array('', '', '', ''), $doc->saveHTML()));
I am using PHP> 5.4
Cgeorges
source share