#125 file_get_html - empty string

v1.0_(example)
closed
nobody
None
1
2014-05-29
2013-03-22
Rob_M
No

When I connecting with $html = file_get_html("www.example.com") and server have opened port 80 but is empty (not have html code), function (for example) $html->find('a') is crashing...

Discussion

  • hlcb
    hlcb
    2014-05-28

    Close this ticket, is a timeout error and php code.

    An empty string is considered to be false, there is no analysis of the DOM of the page, and then immediately run you $dom->find, find method is running on a non-object (false), then you run the str_get_html function, and is necessary to check if it is false then the script has finished running, otherwise proceeds normally.

    $dom = file_get_html( 'https://www.google.com/' );
    
    if ( !$dom ) {
        die( 'Error' );
    }
    
    $tables = $dom->find( 'table' );
    
     
  • John Schlick
    John Schlick
    2014-05-29

    • status: open --> closed