jeudi 7 juillet 2016

Fatal error: Uncaught Error: Call to a member function find() on boolean

I am using a simple HTML DOM parser to parse HTML, but it gives me the following error:

Fatal error: Uncaught Error: Call to a member function find() on boolean in D:xammphtdocswdownload.php:6 Stack trace: #0 D:xammphtdocswdownload.php(72): lastlink(NULL) #1 {main} thrown in D:xammphtdocswdownload.php on line 6

My file is used to download images from an external link. Here is my code to get last img src. It is on line 6

function lastlink($url) {
    $html = new simple_html_dom();
    $html = str_get_html($url);
    if (is_bool($html)) {
        echo 'kuta';
    } else {
        $bbz = $html->find('img', -1)->src;
    }
    return $bbz;
}

$str is some HTML code, from which I want to get the img src.

$str = '<img class="alignnone size-full wp-image-278" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKGQ8YO0GIgtYm2JS9GBbpFlJOZPkJyP09heOhi-UyUdPFJa42Hqsp3vzIl-GuTjbMyQOhkyBe-vIzZk20CF7y4hHIWehNuVeCk_kO1qRbpsALLsMzhK9bQJLRB_SaZs8d9haZpPHSCfg/s1600/The+Witch+2015+English+BluRay.jpg" alt="169.jpg" width="182" height="268" />Some text is there <a href="http://www.google.com" target="_blank" rel="noreferrer">Google</a><img src="http://localhost/ds.jpg" alt="local" />';

What is wrong in this thing, can anyone help me.

Aucun commentaire:

Enregistrer un commentaire