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:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?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';
}
?>

chevron_right


Output:

Yes ! object is empty.

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:

No ! object isn't empty.

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

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.