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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -