Saturday, November 22, 2025
HomeLanguagesPHP | DOMImplementation createDocumentType() function

PHP | DOMImplementation createDocumentType() function

The DOMImplementation::createDocumentType() function is an inbuilt function in PHP which is used to create an empty DOMDocumentType object. Entity declarations and notations are not available.

Syntax:

DOMDocumentType DOMImplementation::createDocumentType
( string $qualifiedName = NULL, string $publicId = NULL,
 string $systemId = NULL )

Parameters:This function accepts three parameters as mentioned above and described below:

  • $qualifiedName (Optional): It specifies the qualified name of the document type to create.
  • $publicId (Optional): It specifies the qualified name of the external subset public identifier.
  • $systemId (Optional): It specifies the external subset system identifier.

Return Value: This function returns DOMDocumentType node with its ownerDocument set to NULL.

Exceptions: This function throws DOM_NAMESPACE_ERR, if there is an error with the namespace, as determined by $qualifiedName.

Below given programs illustrate the DOMImplementation::createDocumentType() function in PHP:
Program 1:




<?php
  
// Creates an instance of the DOMImplementation class
$imp = new DOMImplementation();
  
// Creates a DOMDocumentType instance
$dtd = $imp->createDocumentType(
  
// Get the systemId
echo $dtd->systemId;
?>


Output:

http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd

Program 2:




<?php
// Creates an instance of the DOMImplementation class
$imp = new DOMImplementation();
  
// Creates a DOMDocumentType instance
$dtd = $imp->createDocumentType('neveropen');
  
// Get the name
echo $dtd->name;
?>


Output:

neveropen

Reference: https://www.php.net/manual/en/domimplementation.createdocumenttype.php

RELATED ARTICLES

Most Popular

Dominic
32407 POSTS0 COMMENTS
Milvus
97 POSTS0 COMMENTS
Nango Kala
6784 POSTS0 COMMENTS
Nicole Veronica
11931 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11999 POSTS0 COMMENTS
Shaida Kate Naidoo
6907 POSTS0 COMMENTS
Ted Musemwa
7168 POSTS0 COMMENTS
Thapelo Manthata
6863 POSTS0 COMMENTS
Umr Jansen
6848 POSTS0 COMMENTS