我编写了以下代码来获取网页的标题。但是代码不起作用并输出此错误消息: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>";
}
你能给我举个例子吗?