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

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -