这是我的代码。和功能不起作用ob_flush()
。flush()
为什么?
<?php
function get_headers_curl($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 4);
$r = curl_exec($ch);
$r = split("\n", $r);
return $r;
}
$urls = file('users.txt', FILE_IGNORE_NEW_LINES);
foreach ($urls as $url) {
$headers = get_headers_curl(trim($url));
if (false !== stripos(implode("\n", $headers), "Apache")) {
echo "$url ====> ok" ;
ob_flush();
flush();
}
}
?>