Menu

#124 file_get_html - Timeout

closed
None
2018-12-06
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 busy, function file_get_html() is witing on and on and on.
file_get_html() not have a timeout.

Discussion

  • hlcb

    hlcb - 2014-05-28

    This kind of timeout error can be corrected are likely to increase the time limit using ini_set. Additionally, you may also need to include set_time_limit.

    ini_set( 'default_socket_timeout', 120 );
    set_time_limit( 120 );
    
     
  • LogMANOriginal

    LogMANOriginal - 2018-12-06

    file_get_html is a very limited function useful for quick tests, but not the best solution for real implementations. The solution @hlcb suggested is correct. Your current timeout is likely very high and makes the script wait for a very long time.

    Of course, cURL provides much better support for customization.

    Anyway, I'm closing this issue due to age.

     
  • LogMANOriginal

    LogMANOriginal - 2018-12-06
    • status: open --> closed
    • assigned_to: LogMANOriginal
     

Log in to post a comment.