2

I use SIMPLE HTML DOM for parsing. Some pages take a very long time when i try to get contents. I need to set limit (for example 10 sec) -> go to the next page. Please without socket!

Philipp Klemeshov
  • 383
  • 1
  • 5
  • 14

1 Answers1

10

You can use the HTTP context option

So the code would look like

$options = stream_context_create(array('http'=>
    array(
    'timeout' => 10 //10 seconds
    )
));
echo file_get_contents('http://example.com/', false, $options);
HSR
  • 141
  • 1
  • 9