The DOMImplementation::__construct() function is an inbuilt function in PHP which is used to create a new DOMImplementation object.
Syntax:
DOMImplementation::__construct( void )
Parameters: This function doesn’t accept any parameter.
Below examples illustrate the DOMImplementation::__construct() function in PHP:
Example 1:
<?php // Create a DOMImplementation instance $documentImplementation = new DOMImplementation(); // Create a document $document = $documentImplementation->createDocument(null, 'html'); // Get the document element $html = $document->documentElement; // Create few element $heading = $document->createElement('h1'); $text = $document->createTextNode('neveropen'); // Append the children $heading->appendChild($text); $html->appendChild($heading); // Render the XML echo $document->saveXML(); ?> |
Output:
Example 2:
<?php // Create a DOMImplementation instance $documentImplementation = new DOMImplementation(); // Create a document $document = $documentImplementation->createDocument(null, 'html'); // Get the document element $html = $document->documentElement; // Create few element $head = $document->createElement('head'); $title = $document->createElement('title'); $text = $document->createTextNode('neveropen'); $body = $document->createElement('body'); // Append the children $title->appendChild($text); $head->appendChild($title); $html->appendChild($head); $html->appendChild($body); // Render the XML echo $document->saveXML(); ?> |
Output:
Reference: https://www.php.net/manual/en/domimplementation.construct.php

