Php 冲洗和ob冲洗不工作

Php 冲洗和ob冲洗不工作,php,Php,这是我的密码。ob\u 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,

这是我的密码。
ob\u 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();
    }
}
?>

如果您在使用flush命令时遇到问题,有几件事需要检查

在php.ini文件中(或ht access,甚至在脚本中) 设置以下值

output_buffering 0
zlib.output_compression = Off
zlib.output_compression_level = -1

default_charset = "utf-8"

另外,我注意到您的代码中没有ob_start

请提供更多信息。。会发生什么?它是否执行整个脚本并将其作为正常输出或输出?您使用的是什么环境?我有一个类似的问题-@kris不,问题不是每个url都没有结果,因为所有操作都完成了,它显示了结果我想要每个url的结果我在其他函数中使用过flush,但这里有一些错误,我认为是ob_flush和flush在它们的位置?我在脚本中没有看到ob_start