<?php
$domDocument
=
new
DOMDocument(
'1.0'
);
$root
=
$domDocument
->createElement(
'html'
);
$root
=
$domDocument
->appendChild(
$root
);
$head
=
$domDocument
->createElement(
'head'
);
$head
=
$root
->appendChild(
$head
);
$title
=
$domDocument
->createElement(
'title'
);
$title
=
$head
->appendChild(
$title
);
$text
=
$domDocument
->createTextNode(
'DOMDocument::saveHTML() function'
);
$text
=
$title
->appendChild(
$text
);
$body
=
$domDocument
->createElement(
'body'
);
$body
=
$root
->appendChild(
$body
);
$h1
=
$domDocument
->createElement(
'h1'
);
$h1
=
$body
->appendChild(
$h1
);
$text
=
$domDocument
->createTextNode(
'GeeksforGeeks'
);
$text
=
$h1
->appendChild(
$text
);
$h2
=
$domDocument
->createElement(
'h2'
);
$h2
=
$body
->appendChild(
$h2
);
$text
=
$domDocument
->createTextNode(
'DOMDocument::saveHTML() function'
);
$text
=
$h2
->appendChild(
$text
);
$domDocument
->saveHTMLFile(
'gfg.html'
);
echo
"HTML file saved successfully"
;
?>