Reputation: 21
I'm trying to get the content from some website but if the website is down, it takes a really long time to open (like 1 min).
$html = new DOMDocument();
@$html->loadHtmlFile('http://somewebsite.com');
$xpath = new DOMXPath($html);
$links = $xpath->query("//p[@class='result']");
How can I make it timeout after 5 seconds?
Upvotes: 2
Views: 819