html - how to get a title of a webpage using php? -


i wrote following code title of webpage. code doesn't work , output error message: object of class domelement not converted string

$html = file_get_contents("http://mysmallwebpage.com/"); $dom = new domdocument; @$dom->loadhtml($html);  $links = $dom->getelementsbytagname('title');  foreach ($links $title) {                    echo (string)$title."<br>"; } 

could please show me example?


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

asp.net - Configuring WCF Services in Code WCF 4.5 -