PHP 8.1.28 Released!


(PHP 5, PHP 7, PHP 8)

DOMText::isWhitespaceInElementContent このテキストノードが空白を含むかどうかを示す


public DOMText::isWhitespaceInElementContent(): bool

このテキストノードが空白のみを含む(あるいは空である)かどうかを示します。 このテキストノードが要素の内容に空白を含むかどうかは、 ドキュメントの読み込み時に決定されます。




ノードにゼロ個以上の空白文字だけが含まれる場合に true、 それ以外の場合に false を返します。

add a note

User Contributed Notes 2 notes

permidion at yahoo dot com
19 years ago
if you have an xml element such as <name>Foo Bar</name> (note the space), isWhitespaceInElementContent will return false.
However it will return true for <name><name> or <name/>
so, that function can be used to determine if the element has a text content or not
16 years ago
To add to `permidion at yahoo dot com''s comment:

Quite true. According to DOM Level 3 Core, the `isWhitespaceInElementContent()' method indicates, whether the node contains `whitespace in element content' (or `element content whitespace' according to the newer spec), see [1].

Btw, it seems the `isWhitespaceInElementContent()' method was replaced with the `isElementContentWhitespace' attribute in the current W3C recommendation, see [2].

I have the feeling, though, it would be more precise with the word `only' added, like: `... indicates, whether the node contains *only* element content whitespace.' This would better correspond with the fact the result is false, when there are any non-whitespace characters present (in addition to the whitespace ones), as already noted.

[1] (please concatenate the following two lines)
[2] (please concatenate the following two lines)
To Top