DOMImplementation::createDocument

(PHP 5, PHP 7, PHP 8)

DOMImplementation::createDocument Creates a DOMDocument object of the specified type with its document element

Description

public DOMImplementation::createDocument(?string $namespace = null, string $qualifiedName = "", ?DOMDocumentType $doctype = null): DOMDocument|false

Creates a DOMDocument object of the specified type with its document element.

Parameters

namespace

The namespace URI of the document element to create.

qualifiedName

The qualified name of the document element to create.

doctype

The type of document to create or null.

Return Values

A new DOMDocument object or false on error. If namespace, qualifiedName, and doctype are null, the returned DOMDocument is empty with no document element

Errors/Exceptions

DOM_WRONG_DOCUMENT_ERR

Raised if doctype has already been used with a different document or was created from a different implementation.

DOM_NAMESPACE_ERR

Raised if there is an error with the namespace, as determined by namespace and qualifiedName.

Prior to PHP 8.0.0 this method could be called statically, but would issue an E_DEPRECATED error. As of PHP 8.0.0 calling this method statically throws an Error exception

Changelog

Version Description
8.0.3 namespace is now nullable.
8.0.0 doctype is now nullable.

See Also