I wrote the following code to get the title of a webpage. But the code doesn't work and output this error message: 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>";
}
Could you please show me with an example?
";` needs to be `echo $title->nodeValue."
";` – kittycat Apr 20 '13 at 07:41