0
爲什麼我收到以下錯誤PHP - 錯誤與DOM文檔
Call to a member function getElementsByTagName() on a non-object
錯誤發生在下面一行:
$title = $htm->getElementsByTagName('title');
當我運行下面的代碼:
$dom = new DOMDocument();
foreach ($all as $blog) {
sleep(1);
$htm = $dom->loadHTML(fetch_url('http://' . rtrim(preg_replace('/^http:\/\//i', '', $blog['blogurl']), '/')));
if ($htm) {
//check TITLE
$title = $htm->getElementsByTagName('title');
$title = $title->item(0)->nodeValue;
if (preg_match('/private/i', $title)) {
private_blog($blog['id']);
$title = null;
unset($title);
gc_collect_cycles();
continue;
}
}
}