PHP 8.4.24 Released!

Voting

: min(zero, five)?
(Example: nine)

The Note You're Voting On

Jerry Ellis
21 years ago
1st argument) a node to insert 
2nd argument) a reference node - this is the node that the new node will be inserted before

The trick to using this method is that the OBJECT on which you actually CALL the insertBefore() method is actually the PARENT node of the reference node!  

INCORRECT:
$DOMNode_refNode->insertBefore($DOMNode_newNode, $DOMNode_refNode); 

CORRECT:
$DOMNode_refNode->parentNode->insertBefore($DOMNode_newNode, $DOMNode_refNode);

<< Back to user notes page

To Top