file_get_contents 超时导致cpu 100%的解决方案
<?php
$ctx = stream_context_create(array(
'http' => array(
'timeout' => 1 //设置一个超时时间,单位为秒
)
)
);
file_get_contents("http://example.com/", 0, $ctx);
?>
设置一个超时时间就可以,可以自行封装函数
<?php
$ctx = stream_context_create(array(
'http' => array(
'timeout' => 1 //设置一个超时时间,单位为秒
)
)
);
file_get_contents("http://example.com/", 0, $ctx);
?>
设置一个超时时间就可以,可以自行封装函数