开发者

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*/ }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜