PHP | DOMCharacterData appendData() Function Last Updated : 20 Feb, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report The DOMCharacterData::appendData() function is an inbuilt function in PHP which is used to append the string to the end of the character data of the node. Syntax: public DOMCharacterData::appendData( string $data ) Parameters: This function accepts a single parameter $data which holds the string that need to append. Return Value: This function does not return any value. Below given programs illustrate the DOMCharacterData::appendData() function in PHP: Program 1: php <?php // Create a new DOM Document $dom = new DOMDocument('1.0', 'iso-8859-1'); // Create a div element $element = $dom->appendChild(new DOMElement('div')); // Create a DOMCdataSection $text = $element->appendChild( new DOMCdataSection('Hey this is my DOMC')); // Append data at the end $text->appendData(' This is appended text'); echo $dom->saveXML(); ?> <?xml version="1.0" encoding="iso-8859-1"?> <div> <![CDATA[Hey this is my DOMC This is appended text]]> </div> Output: Use Chrome Developer tools to view the HTML or press Ctrl+U Program 2: php <?php // Create a new DOM Document $dom = new DOMDocument('1.0', 'iso-8859-1'); // Create a div element $element = $dom->appendChild(new DOMElement('div')); // Create a DOMCdataSection $text = $element->appendChild( new DOMCdataSection('DOMC Data')); // Overwriting by deleting old data $text->deleteData(0, 9); $text->appendData(' This is appended text'); echo $dom->saveXML(); ?> Output: <?xml version="1.0" encoding="iso-8859-1"?> <div><![CDATA[ This is appended text]]></div> Reference: https://www.php.net/manual/en/domcharacterdata.appenddata.php Comment More infoAdvertise with us Next Article PHP | DOMCharacterData substringData() Function G gurrrung Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-DOM Similar Reads PHP | DOMCharacterData deleteData() Function The DOMCharacterData::deleteData() function is an inbuilt function in PHP which is used to remove a range of characters from the node. Syntax: void DOMCharacterData::deleteData( int $offset, int $count ) Parameters: This function accept two parameters as mentioned above and described below: $offset: 1 min read PHP | ArrayIterator append() Function The ArrayIterator::append() function is an inbuilt function in PHP which is used to append an element into an array iterator. Syntax: void ArrayIterator::append( mixed $value ) Parameters: This function accepts single parameter $value that holds the value that need to be append. Return Value: This f 1 min read PHP | DOMCharacterData insertData() Function The DOMCharacterData::insertData() function is an inbuilt function in PHP which is used to insert a string at the specified 16-bit unit offset. Syntax: void DOMCharacterData::insertData( int $offset, string $data ) Parameters: This function accept two parameters as mentioned above and described belo 2 min read PHP | DOMCharacterData replaceData() Function The DOMCharacterData::replaceData() function is an inbuilt function in PHP which is used to replace a substring within the DOMCharacterData node. Syntax: void DOMCharacterData::replaceData( int $offset, int $count, string $data) Parameters: This function accept three parameters as mentioned above an 2 min read PHP | DOMCharacterData substringData() Function The DOMCharacterData::substringData() function is an inbuilt function in PHP which is used to extracts a range of data from the node. Syntax: string DOMCharacterData::substringData( int $offset, int $count ) Parameters: This function accept two parameters as mentioned above and described below: $off 2 min read PHP | AppendIterator append() Function The AppendIterator::append() function is an inbuilt function in PHP which is used to append an iterator. Syntax: void AppendIterator::append( Iterator $iterator ) Parameters: This function accepts single parameter $iterator which holds the iterator to append. Return Value: This function does not ret 1 min read Like