我编写了以下代码来获取网页的标题。但代码不起作用并输出此错误消息:Object of class DOMElement could not be converted to string
$html = file_get_contents("http://mysmallwebpage.com/");
$dom = new DOMDocument;
@$dom->loadHTML($html);
$links = $dom->getElementsByTagName('title');
foreach ($links as $title)
{
echo (string)$title."<br>";
}
你能告诉我一个例子吗?