PHP | DOMNode hasChildNodes() function Last Updated : 02 Mar, 2020 Comments Improve Suggest changes Like Article Like Report 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 given programs illustrate the DOMNode::hasChildNodes() function in PHP: Program 1: php <?php // Create a new DOMDocument $dom = new DOMDocument(); // Create a paragraph element $element = $dom->createElement('p', 'GeeksforGeeks!'); // Append the child $dom->appendChild($element); // Check if child nodes are there if ($dom->hasChildNodes()) { echo "Yes, child nodes are there."; } ?> Output: Yes, child nodes are there. Program 2: php <?php // Create a new DOMDocument instance and keep it empty $dom = new DOMDocument(); // Check if child nodes are not there if (!$dom->hasChildNodes()) { echo "No, child nodes are not there."; } ?> Output: No, child nodes are not there. Reference: https://www.php.net/manual/en/domnode.haschildnodes.php Comment More infoAdvertise with us Next Article PHP | DOMNode hasChildNodes() function gurrrung Follow Improve Article Tags : Web Technologies PHP PHP-function Similar Reads PHP | DOMNode isSameNode() Function 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 return 2 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 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 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 lookupPrefix() Function The DOMNode::lookupPrefix() function is an inbuilt function in PHP which is used to get the namespace prefix of the node based on the namespace URI.Syntax:  string DOMNode::lookupPrefix( string $namespaceURI ) Parameters: This function accepts a single parameter $namespaceURI which holds the namesp 1 min read PHP | DOMNode isDefaultNamespace() Function The DOMNode::isDefaultNamespace() function is an inbuilt function in PHP which is used to check if the specified namespaceURI is the default namespace or not. Syntax: bool DOMNode::isDefaultNamespace( string $namespaceURI ) Parameters: This function accepts a single parameter $namespaceURI which hol 1 min read PHP | DOMNode removeChild() Function The DOMNode::removeChild() function is an inbuilt function in PHP which is used remove child from list of children. Syntax: DOMNode DOMNode::removeChild( DOMNode $oldnode ) Parameters: This function accepts a single parameter $oldnode which holds the child to remove. Return Value: This function retu 1 min read PHP | DOMDocument importNode() Function The DOMDocument::importNode() function is an inbuilt function in PHP which is used to return a copy of the node which need to import and associates it with the current document. Syntax: DOMNode DOMDocument::importNode( DOMNode $importedNode, bool $deep = FALSE ) Parameters: This function accepts two 2 min read PHP | DOMDocument load() Function The DOMDocument::load() function is an inbuilt function in PHP which is used to load an XML document from a file. Syntax: mixed DOMDocument::load( string $filename, int $options = 0 ) Parameters: This function accepts two parameters as mentioned above and described below: $filename: This parameter h 1 min read Like