PHP | DOMImplementation __construct() Function

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= newDOMImplementation();  // 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('zambiatek');  // Append the children $heading->appendChild($text); $html->appendChild($heading);  // Render the XML echo$document->saveXML(); ?>  | 
Output:
Example 2: 
| <?php // Create a DOMImplementation instance $documentImplementation= newDOMImplementation();  // 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('zambiatek'); $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
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, zambiatek Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
 
				 
					



