怪异的html解析器错误调用成员函数find()

时间:2014-04-08 16:05:18

标签: php parsing dom

解析html时出现此错误

我的代码就像这样

$html = new \simple_html_dom();
$html->load_file($url);
$type = gettype($html);
$this->output->writeln("check point1:" . $type); // it says 'object'
$class = get_class($html);
$this->output->writeln("check point2:" . $class); // it says 'simple_html_dom'
foreach($html->find('a') as $element){
//do something here.
}

然后此代码显示此错误的某些人。

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

错误

即使发生错误,也会正确获取$ html(我检查两个检查点)

这个错误类似于this文章,但没有发现洗脱。

请帮帮我

0 个答案:

没有答案