Fatal error: Call to a member function find() on a non-object using str_get_html()
In the script below, I'm getting an error when the URL is not found or reports 404...
Fatal error: Call to a member function find() on a non-object
How can I code around it?
funct开发者_开发技巧ion processPage(){
$this->html = scrapePage($this->url);
$dom = str_get_html($this->html);
$metakws = $dom->find('meta[name=keywords]'); //ERROR OCCURS HERE WHEN URL NOT FOUND
//etc...
}
Check for
if (!$dom) { /*Error*/ }
Or
if (!is_object($dom)) { /*Error*/ }
精彩评论