array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'fr', ), 'this' => array ( 0 => 'domprocessinginstruction.construct.php', 1 => 'DOMProcessingInstruction::__construct', ), 'up' => array ( 0 => 'class.domprocessinginstruction.php', 1 => 'DOMProcessingInstruction', ), 'prev' => array ( 0 => 'class.domprocessinginstruction.php', 1 => 'DOMProcessingInstruction', ), 'next' => array ( 0 => 'class.domtext.php', 1 => 'DOMText', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'fr', 'path' => 'reference/dom/domprocessinginstruction/construct.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 5, PHP 7, PHP 8)
DOMProcessingInstruction::__construct — Crée un nouvel objet DOMProcessingInstruction
Crée un nouvel objet DOMProcessingInstruction. Cet objet est en lecture seule. Il peut être ajouté à un document, mais les nœuds additionnels ne peuvent pas être ajoutés à ce nœud tant qu'il est associé à un document. Pour créer un nœud accessible en écriture, utilisez DOMDocument::createProcessingInstruction.
name
Le nom du tag de l'instruction.
value
La valeur de l'instruction.
Exemple #1 Création d'un nouveau DOMProcessingInstruction
<?php
$dom = new DOMDocument('1.0', 'UTF-8');
$html = $dom->appendChild(new DOMElement('html'));
$body = $html->appendChild(new DOMElement('body'));
$pinode = new DOMProcessingInstruction('php', 'echo "Bonjour le monde !"; ');
$body->appendChild($pinode);
echo $dom->saveXML();
?>
L'exemple ci-dessus va afficher :
<?xml version="1.0" encoding="UTF-8"?> <html><body><?php echo "Bonjour le monde !"; ?></body></html>