php - file_get_contents issue timeout? -
i wanted make website contact servers whenever have ask data sent want when can't connect 1 server tries next. have @file_get_contents heard timeout doesn't work? how handle when happen.
i heard timeout doesn't work?
you can set timeout file_get_contents() 3rd parameter $context
(context options , parameters) :
$context = stream_context_create(['http' => ['timeout' => 5]]); $html = file_get_contents('http://bit.ly/6wgjo', false, $context);
also how handle when happen.
check file_get_contents
returns false
.
use curl :
- you can magic curl.
- set option
curlopt_timeout
maximum number of seconds allow curl functions execute.
see other options here.
Comments
Post a Comment