html - how to get a title of a webpage using php? -
this question has answer here:
- get meta information, title , images of webpage using php 2 answers
- get title of website via link 10 answers
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
Post a Comment