开发者

Fatal error: Call to a member function find() on a non-object using str_get_html()

开发者 https://www.devze.com 2023-03-28 04:57 出处:网络
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

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

精彩评论

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