PHP file_get_contents function Read the resolution of remote data timeout, C function timeout
The file_get_contents function often fails to read remote data in the case of poor network conditions.
The solution is as follows:
Copy the Code code as follows:
/* Set a time-out mate failed to try multiple reads, the effect is much better than the original */
$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.html www.bkjia.com true http://www.bkjia.com/PHPjc/998805.html techarticle PHP file_get_contents function to read the resolution of remote data timeout, C function timeout in the case of poor network conditions file_get_contents function often read remote data failure. Solve ...