开发者

PHP - Call to a member function find() on a non-object

So this error is killing me, heres the code:

$html = file_get_html('vids.ht开发者_如何学JAVAml');

foreach($html->find('a') as $element) {

        echo $element->name

        }


Did you include the simple_html_dom.php file first?

include_once('/simple_html_dom.php');

And is your vids.html in the same directory you are calling from?


I think you should var_dump($element) inside the loop and see if it has the 'name' property set. YOu could modify your condition and add isset() in the loop,

   foreach($html->find('a') as $element) {
     if(isset($element->name)){
        echo $element->name;
     }
  }
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜