Returns the string content

# SimpleXMLElement::__toString

(PHP 5 >= 5.3.0, PHP 7, PHP 8)

SimpleXMLElement::__toString — Returns the string content

### 说明

public function SimpleXMLElement::__toString(): string

Returns text content that is directly in this element. Does not return text content that is inside this element's children.

### 参数

此函数没有参数。

### 返回值

Returns the string content on success or an empty string on failure.

### 示例

示例 #1 Get string content

    <?php
    $xml = new SimpleXMLElement('<a>1 <b>2 </b>3</a>');
    echo $xml;
    ?>

以上示例会输出：

    1 3

### 参见

- SimpleXMLElement::asXML() - Return a well-formed XML string based on SimpleXML element

`↑` and `↓` to navigate • `Enter` to select • `Esc` to close • `/` to open