PHP | DOMText isElementContentWhitespace() Function

The DOMText::isElementContentWhitespace() function is an inbuilt function in PHP which is used to check whether this text node contains whitespace in element content or not.

Syntax:

bool DOMText::isElementContentWhitespace( void )

Parameters: This function doesn’t accept any parameters.



Return Value: This function returns TRUE on success or FALSE on failure.

Below given programs illustrate the DOMText::isElementContentWhitespace() function in PHP:

Program 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// Create the text Node with no whitespace
$text = new DOMText('No_Space');
  
// Check if whitespace is not there
if(!$text->isElementContentWhitespace()) {
    echo 'No ! Whitespace is not there.';
}
?>

chevron_right


Output:

No ! Whitespace is not there.

Program 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// Create the text Node with a space
$text = new DOMText('Yes Space');
  
// Check if whitespace is there
if($text->isElementContentWhitespace()) {
    echo 'Yes ! Whitespace is there.';
}
?>

chevron_right


Output:

Yes ! Whitespace is there.

Reference: https://www.php.net/manual/en/domtext.iselementcontentwhitespace.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.