- var_dump: documentation ( source)
<?php
$dom = new DOMDocument();
$dom->loadHtml('<!doctype html><html><body></body></html>');
var_dump((boolean) $dom->getElementsByTagName('head')->length ? '<head> available' : '<head> not available');
var_dump((boolean) $dom->getElementsByTagName('body')->length ? '<body> available' : '<body> not available');