Friday, October 3, 2025
HomeLanguagesPHP | DOMText isWhitespaceInElementContent() Function

PHP | DOMText isWhitespaceInElementContent() Function

The DOMText::isWhitespaceInElementContent() function is an inbuilt function in PHP which is used to indicate whether this text node contains whitespace or not. In simple words, this function is used to check if a DOMText object contains text or not.

Syntax:

bool DOMText::isWhitespaceInElementContent( void )

Parameters: This function doesn’t accept any parameter.

Return Value: This function returns TRUE on success.

Below examples illustrate the DOMText::isWhitespaceInElementContent() function in PHP:

Example 1:




<?php
  
// Create the DOMText without text
$text = new DOMText();
  
// Check if whitespace is there
if($text->isWhitespaceInElementContent()) {
    echo 'Yes ! object is empty.';
} else {
    echo 'NO it is not empty';
}
?>


Output:

Yes ! object is empty.

Example 2:




<?php
  
// Create a DOMText with text
$text = new DOMText('Geeksforneveropen');
  
// Check if whitespace is there
if(!$text->isWhitespaceInElementContent()) {
    echo 'No ! object isn\'t empty.';
} else {
    echo 'Object is empty';
}
?>


Output:

No ! object isn't empty.

Reference: https://www.php.net/manual/en/domtext.iswhitespaceinelementcontent.php

RELATED ARTICLES

Most Popular

Dominic
32332 POSTS0 COMMENTS
Milvus
85 POSTS0 COMMENTS
Nango Kala
6703 POSTS0 COMMENTS
Nicole Veronica
11868 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11929 POSTS0 COMMENTS
Shaida Kate Naidoo
6819 POSTS0 COMMENTS
Ted Musemwa
7080 POSTS0 COMMENTS
Thapelo Manthata
6775 POSTS0 COMMENTS
Umr Jansen
6776 POSTS0 COMMENTS