$dom = new DomDocument(); $dom->loadHtml(file_get_contents('http://example.com'));
$html = 'Example Page Welcome to the Example Page
'; $dom = new DomDocument(); $dom->loadHtml($html);
$options = array( 'encoding' => 'UTF-8', 'validateOnParse' => true ); $dom = new DomDocument(); $dom->loadHtml(file_get_contents('http://example.com'), $options);This code loads the HTML from the specified URL and applies the specified options, such as setting the character encoding and enabling validation during parsing.