PHP | DOMDocument createEntityReference() Function Last Updated : 27 Aug, 2019 Comments Improve Suggest changes Like Article Like Report The DOMDocument::createEntityReference() function is an inbuilt function in PHP which is used to create a new instance of class DOMEntityReference. Syntax: DOMEntityReference DOMDocument::createEntityReference( string $name ) Parameters: This function accepts single parameter $name which holds the content of the entity reference. The entity reference does not contains leading & and the trailing ; characters. Returns Value: This function returns the new DOMEntityReference object on success or FALSE on failure. Below programs illustrate the DOMDocument::createEntityReference() function in PHP: Program 1: php <?php // Create a new DOMDocument object $domDocument = new DOMDocument('1.0', 'iso-8859-1'); // Use createEntityReference() function to create // new entity reference node $domER = $domDocument->createEntityReference('nbsp'); // Append element to the document $domDocument->appendChild($domER); // Save the XML document and display it echo $domDocument->saveXML(); ?> Output: <?xml version="1.0" encoding="iso-8859-1"?> Program 2: php <?php // Create a new DOMDocument object $domDocument = new DOMDocument('1.0', 'iso-8859-1'); // Use createEntityReference() function to create // new entity reference node $domER1 = $domDocument->createEntityReference('amp'); $domER2 = $domDocument->createEntityReference('lt'); $domER3 = $domDocument->createEntityReference('gt'); $domER4 = $domDocument->createEntityReference('reg'); // Append element to the document $domDocument->appendChild($domER1); $domDocument->appendChild($domER2); $domDocument->appendChild($domER3); $domDocument->appendChild($domER4); // Save the XML document and display it echo $domDocument->saveXML(); ?> Output: <?xml version="1.0" encoding="iso-8859-1"?> & < > ® Reference: https://www.php.net/manual/en/domdocument.createentityreference.php Comment More infoAdvertise with us Next Article PHP | DOMDocument createEntityReference() Function jit_t Follow Improve Article Tags : Web Technologies PHP PHP-function Similar Reads PHP | DOMDocument createElement() Function The DOMDocument::createElement() function is an inbuilt function in PHP which is used to create a new instance of class DOMElement. Syntax: DOMElement DOMDocument::createElement( string $name, string $value ) Parameters: This function accepts two parameters as mentioned above and described below: $n 2 min read PHP | DOMDocument createTextNode() Function The DOMDocument::createTextNode() function is an inbuilt function in PHP which is used to create a new instance of class DOMText. Syntax: DOMText DOMDocument::createTextNode( string $content ) Parameters: This function accepts single parameter $content which holds the content of the text. Return Val 1 min read PHP | DOMDocument createAttributeNS() Function The DOMDocument::createAttributeNS() function is an inbuilt function in PHP which is used to create a new attribute node with an associated namespace. Syntax: DOMAttr DOMDocument::createAttributeNS( string $namespaceURI, string $qualifiedName ) Parameters: This function accepts two parameters as men 2 min read PHP | DOMDocument createDocumentFragment() Function The DOMDocument::createDocumentFragment() function is an inbuilt function in PHP which is used to create a new document fragment. Syntax: DOMDocumentFragment DOMDocument::createDocumentFragment( void ) Parameters: This function doesnât accepts any parameters. Return Value: This function returns a ne 2 min read PHP | DOMDocument createAttribute() Function The DOMDocument::createAttribute() function is an inbuilt function in PHP which is used to create a new instance of class DOMAttr. Syntax: DOMAttr DOMDocument::createAttribute( string $name ) Parameters: This function accepts single parameter $name which holds the name of the attribute. Return Value 2 min read PHP DOMDocument createElementNS() Function The DOMDocument::createElementNS() function is an inbuilt function in PHP that is used to create a new element node with an associated namespace. Syntax: DOMElement DOMDocument::createElementNS( string $namespaceURI, string $qualifiedName, string $value ) Parameters: This function accepts three para 2 min read PHP | DOMDocument createComment() Function The DOMDocument::createComment() function is an inbuilt function in PHP which is used to create a new instance of class createComment. Syntax: DOMComment DOMDocument::createComment( string $data ) Parameters: This function accepts single parameter $data which holds the content of the comment node. R 2 min read PHP | DOMDocument createCDATASection() Function The DOMDocument::createCDATASection() function is an inbuilt function in PHP which is used to create a new instance of class DOMCDATASection. Syntax: DOMCDATASection DOMDocument::createCDATASection( string $data ) Parameters: This function accepts single parameter $data which holds the content of th 1 min read PHP DOMDocument createProcessingInstruction() Function The DOMDocument::createProcessingInstruction() function is an inbuilt function in PHP that is used to create a new instance of the class DOMProcessingInstruction. Syntax: DOMProcessingInstruction DOMDocument::createProcessingInstruction( $target, $data ) Parameters: This function accepts two paramet 1 min read PHP | DOMDocument __construct() Function The DOMDocument::__construct() function is an inbuilt function in PHP which is used to create a new DOMDocument object. Syntax: public DOMDocument::__construct( string $version, string $encoding ) Parameters: This function accepts two parameters as mentioned above and described below: $version: This 1 min read Like