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?

function 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... }

-------------Problems Reply------------

Check for

if (!$dom) { /*Error*/ }

Or

if (!is_object($dom)) { /*Error*/ }

Category:php Views:3 Time:2011-08-14

Related post

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.142 (s). 11 q(s)