Maison >développement back-end >tutoriel php >PHP file_get_contents 设置超时时间
$opts = array('http' =>
array(
'method' => 'GET',
'timeout' => 3
)
);
$context = stream_context_create($opts);
$url = "www.google.com";
$text = @file_get_contents($url,false,$context,-1,100);
if($text==FALSE){
return FALSE;
}
return TRUE;