Zubrag.com :: Forum

Programmers Lounge => Tips and Tricks => Topic started by: zubrag on April 23, 2007, 03:25:47 PM



Title: How to set timeout for file_get_contents (socket timeout)
Post by: zubrag on April 23, 2007, 03:25:47 PM
You may need to set timeout on http request in case remote host is not responding.
Set the socket timeout as follows:

// set socket timeout
ini_set('default_socket_timeout', 120);

// read page contents
$request = file_get_contents("http://www.zubrag.com");