SimpleXMLElement::__toString

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

SimpleXMLElement::__toStringReturns the string content

說(shuō)明

public SimpleXMLElement::__toString(): string

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

參數(shù)

此函數(shù)沒(méi)有參數(shù)。

返回值

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

以上例程會(huì)輸出:

1 3

參見(jiàn)