The function c times out. PHPfile_get_contents function reading remote data timeout solution, c function timeout in poor network conditions file_get_contents function reading remote data often fails. Solution for PHP file_get_contents function reading remote data timeout, c function timeout
In poor network conditions, the file_get_contents function often fails to read remote data.
The solution is as follows:
The code is as follows:
/* Try to read the data multiple times after the timeout setting fails. The effect is much better than before */
$ Url = 'http: // www.bkjia.com ';
$ Opts = array (
'Http' => array (
'Method' => "GET ",
'Timeout' => 1, // set timeout
)
);
$ Context = stream_context_create ($ opts );
$ Contents = @ file_get_contents ($ url, false, $ context );
?>
Http://www.bkjia.com/PHPjc/998805.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/998805.htmlTechArticlePHP file_get_contents function read remote data timeout solution, c function timeout in poor network conditions file_get_contents function often read remote data failure. Solution...