重构file_get_contents实现一个带超时链接访问的函数
function wp_file_get_contents($url, $timeout = 30)
{
$context = stream_context_create(array(
'http' => array(
'timeout' => $timeout // 超时时间,单位为秒
)
));
return file_get_contents($url, false, $context);
}
只言片语任我说,提笔句句无需忖。落笔不知寄何人,唯有邀友共斟酌。