[英]Error using PHP Simple HTML DOM parser
if (!is_null($elements)) {
$embeds = array();
foreach ($elements as $element) {
if (trim(strip_tags($element->innertext)) == $episode_term) {
$html2 = file_get_html($element->href);
$elements2 = $html2->find('#streamlinks .sideleft a');
if (!is_null($elements2)) {
foreach ($elements2 as $element) {
$html3 = file_get_html($element->href);
$iframe_element = $html3->find('.frame', 0);
if (!is_null($iframe_element)) {
$embed = $misc->buildEmbed($iframe_element->src);
if ($embed) {
$embeds[] = array(
"embed" => $embed,
"link" => $iframe_element->src,
"language" => "ENG",
);
}
}
}
}
}
}
return $embeds;
}
Blockquote
PHP Fatal error: Call to a member function find() on a non-object inBlockquote
PHP致命错误:在非对象中调用成员函数find()$elements2 = $html2->find('#streamlinks .sideleft a');
so its confusing as to what is causing this error to appear in my error log file? 因此,对于导致该错误出现在我的错误日志文件中的原因,它感到困惑吗?
I'd try to output $element->href
befor you do the file_get_html. 在尝试执行file_get_html之前,我会尝试输出$element->href
。 If the file_get_html can't get a page $html2
stays uniinitialized and you can't use find on it. 如果file_get_html无法获取页面$html2
保持未初始化,则无法在其上使用find。
Beside that you could build a check wether $html2
is set after the file_get_html and output an error if not. 此外,您可以建立检查,然后在file_get_html之后设置$html2
,如果没有,则输出错误。 I usually use something like this: 我通常使用这样的东西:
if($html2 == false || $html2 == NULL){
// no html found
}else{
// html found
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.