PHP | DOMNode isSameNode() Function Last Updated : 05 Mar, 2020 Comments Improve Suggest changes Like Article Like Report The DOMNode::isSameNode() function is an inbuilt function in PHP which indicates if two nodes are the same node or not. Syntax: bool DOMNode::isSameNode( DOMNode $node ) Parameters: This function accepts a single parameter $node which holds the node to be compared. Return Value: This function returns TRUE on success or FALSE on failure. Below given programs illustrate the DOMNode::isSameNode() function in PHP: Program 1: php <?php // Create a new DOMDocument $dom = new DOMDocument(); // Create a paragraph element with a namespace $p_element = $dom->createElementNS( 'my_namespace', 'p', 'GeeksforGeeks'); // Append the child to DOMDocument $dom->appendChild($p_element); // Check if the node is same $isSameNode = $dom->isSameNode($dom); // Check if the namespace is default or not if($isSameNode) { echo 'Yes, $dom is same to itself.'; } ?> Output: Yes, $dom is same to itself. Program 2: php <?php // Create a new DOMDocument $dom = new DOMDocument(); // Create a paragraph element with a namespace $p_element = $dom->createElementNS( 'my_namespace', 'p', 'GeeksforGeeks'); // Append the child to DOMDocument $dom->appendChild($p_element); // Create another new DOMDocument instance $dom2 = new DOMDocument(); // Check if nodes are same $isSameNode = $dom->isSameNode($dom2); // Check if the namespace is default or not if(!$isSameNode) { echo 'No, $dom and $dom2 are different.'; } ?> Output: No, $dom and $dom2 are different. Reference: https://www.php.net/manual/en/domnode.issamenode.php Comment More infoAdvertise with us Next Article PHP | DOMNode isSameNode() Function G gurrrung Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-DOM Similar Reads PHP | DOMNode isSupported() Function The DOMNode::isSupported() function is an inbuilt function in PHP which is used to check if the asked feature is supported for the specified version. Syntax: bool DOMNode::isSupported( string $feature, string $version ) Parameters: This function accepts two parameters as mentioned above and describe 2 min read PHP | DOMNode getLineNo() function The DOMNode::getLineNo() function is an inbuilt function in PHP which is used to get the line number for where the node is defined. Syntax: DOMNode DOMNode::getLineNo( void ) Parameters:This function doesnât accept any parameter. Return Value: This function returns the line number where the node was 2 min read PHP | DOMNode insertBefore() Function The DOMNode::insertBefore() function is an inbuilt function in PHP which is used to insert a new node before a certain another node. Syntax: DOMNode DOMNode::insertBefore( DOMNode $newNode, DOMNode $refNode ) Parameters:This function accepts two parameters as mentioned above and described below: $ne 2 min read PHP | DOMNode hasChildNodes() function The DOMNode::hasChildNodes() function is an inbuilt function in PHP which is used to check if node has children or not. Syntax: bool DOMNode::hasChildNodes( void ) Parameters:This function doesnât accept any parameter. Return Value: This function returns TRUE on success or FALSE on failure. Below gi 1 min read PHP | DOMNode normalize() Function The DOMNode::normalize() function is an inbuilt function in PHP which is used to remove empty text nodes and merge adjacent text nodes in this node and all its children. Syntax: void DOMNode::normalize( void ) Parameters: This function doesnât accept any parameters. Return Value: This function does 2 min read Like