2017-07-09 1 views
-1

PHPシンプルなHTML DOMパーサ致命的なエラー:それをしないのはなぜ行に/home/admin/web//public_html/index.phpにブールにメンバー関数find()に14

Fatal error: Call to a member function find() on boolean in /home/admin/web//public_html/index.php on line 14

を呼び出し失敗します?

include("simple_html_dom.php"); 

$html = file_get_html('http://en.wikipedia.org/wiki/facebook'); 

$title = $html->find('h1[id=firstHeading]',0)->innertext; 

echo $title; 
+0

$ htmlのvarがオブジェクトではありません。 file_get_htmlが返すものを確認してください! – BenRoob

+1

あなたの 'file_get_html()'関数は実行に失敗しました。 –

+0

異なるページが動作します。 例http://en.wikipedia.org/wiki/apple – xeuy

答えて

0

私はfile_get_htmlに慣れていないですが、あなたは戻り値をチェックする必要がありますので、それはおそらく、エラー時にfalseを返します。

if ($html === false) { 
    // check what the error is (look for file_get_html documentation to understand how to get more info on the error 
} else { 
    // file is ok, process it 
} 
+0

'file_get_html()'は、よく使われるSimple HTML DOMパーサライブラリの一部です。 – Barmar

関連する問題