$html = file_get_html('https://stackoverflow.com/');
$head = $html->find('head', 0);
echo $head->content;