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!
Asked
Active
Viewed 5,377 times
1 Answers
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