Someone16

PHP: file_get_contents timeout

by someone16 on Oct.30, 2009, under Programming

How to set timeout when fetching content from web site with file_get_contents?
<?php
$context = stream_context_create(array('http' => array('timeout' > 1)));
echo file_get_contents("http://example.com/", 0, $context);
?>

It's a good idea to use it with timeout, because otherwise default timeout from php.ini will be used.
:php

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...