PHP DOMDocument createProcessingInstruction() Function Last Updated : 03 Apr, 2023 Comments Improve Suggest changes Like Article Like Report 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 parameters as mentioned above and described below: $target: This parameter holds the target of the processing instruction.$data: This parameter holds the content of the processing instruction. Return Value: This function returns the new DOMProcessingInstruction on success or FALSE on failure. Below examples illustrate the DOMDocument::createProcessingInstruction() function in PHP: Example 1: php <?php // Create a new DOMDocument $domDocument = new DOMDocument('1.0', 'iso-8859-1'); // Use createProcessingInstruction() function to create // a new Processing Instruction node $domPI = $domDocument->createProcessingInstruction("name", "GeeksforGeeks"); // Append element to the document $domDocument->appendChild($domPI); // Create XML document and display it echo $domDocument->saveXML(); ?> Output:<?xml version="1.0" encoding="iso-8859-1"?> <?name GeeksforGeeks?> Example 2: php <?php // Create a new DOMDocument $domDocument = new DOMDocument('1.0', 'iso-8859-1'); // Use createProcessingInstruction() function to create // a new Processing Instruction node $domPI1 = $domDocument->createProcessingInstruction("name", "GeeksforGeeks"); $domPI2 = $domDocument->createProcessingInstruction("contact", "Noida"); $domPI3 = $domDocument->createProcessingInstruction("email", "[email protected]"); // Append element to the document $domDocument->appendChild($domPI1); $domDocument->appendChild($domPI2); $domDocument->appendChild($domPI3); // Create XML document and display it echo $domDocument->saveXML(); ?> Output:<?xml version="1.0" encoding="iso-8859-1"?> <?name GeeksforGeeks?> <?contact Noida?> <?email [email protected]?> Reference: https://www.php.net/manual/en/domdocument.createprocessinginstruction.php Comment More infoAdvertise with us Next Article PHP DOMDocument createProcessingInstruction() Function J jit_t Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-DOM Similar Reads 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 __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 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 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 createEntityReference() Function 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 c 1 min read Like