iis+php中flush失效??我在apache里都试过了,没问题,但是一放到iis的机器就失效了???在网上看过一些文章,iis里的站点,“启动缓冲”已经把勾去掉了,但还是不行???是不是还有什么时候配置??急呀谢谢谢谢谢谢

解决方案 »

  1.   

    flash
      

  2.   

    我觉得应该就是  flush的问题<?
    include_once("../../include/global.php");
    cookie_admin(); include_once("../../include/class.phpmailer.php");
    set_time_limit(0); $db=initdb(); $dept_result=$db->query("select * from dept ORDER BY `id`"); if($send_mail)
    {
    $select_user_input=$_POST[select_user_input];
    $send_title=htmlspecialchars($_POST[send_title]);
    $send_text=htmlspecialchars($_POST[send_text]); $mail = new PHPMailer(); //建立邮件发送类
    $mail->IsSMTP(); // 使用SMTP方式发送
    $mail->Host = "mail.qq.com.cn"; // 您的企业邮局域名
    $mail->SMTPAuth = true; // 启用SMTP验证功能
    $mail->Username = "[email protected]"; // 邮局用户名(请填写完整的email地址)
    $mail->Password = "12345"; // 邮局密码
    $mail->From = "[email protected]"; //邮件发送者email地址
    $mail->FromName = "名子"; if($select_user_input!='全体')
    {
    $select_user_input=substr_replace($select_user_input,'',-1);
    $send_user=explode("|",$select_user_input); $width = 500;                      //显示的进度条长度,单位 px
    $total = count($send_user);     //总共需要操作的记录数
    $pix = $width / $total;        //每条记录的操作所占的进度条单位长度
    $progress = 0; //当前进度条长度 echo "
    <html>
    <head>
        <style>
        body, div input { font-family: Tahoma; font-size: 9pt }
        </style>
        <script language=\"JavaScript\">
        function updateProgress(sMsg, iWidth)
        {
            document.getElementById(\"status\").innerHTML = sMsg;
            document.getElementById(\"progress\").style.width = iWidth + \"px\";
            document.getElementById(\"percent\").innerHTML = parseInt(iWidth / $width * 100) + \"%\";
         }
        </script>
    </head><body style=\"margin:0; padding:0;\" bgcolor=\"#dfdfdf\">
    <br><br>
    <div style=\"margin: 80px; padding: 8px; border: 1px solid gray; background: #EAEAEA; width:".($width+8)."px;\">";
        echo "<div></div>
        <div style=\"padding: 0; background-color: white; border: 1px solid navy; width:$width px\">
        <div id=\"progress\" style=\"padding: 0; background-color: #FFCC66; border: 0; width: 0px; text-align: center;   height: 16px\"></div>
        </div>
        <div id=\"status\">&nbsp;</div>
        <div id=\"percent\" style=\"position: relative; top: -30px; text-align: center; font-weight: bold; font-size: 8pt\">0%</div>
    </div>\n";
    ob_flush();
    flush();    //将输出发送给客户端浏览器 $success = true ; foreach ($send_user as $send_user_value)
    {
    $username_email=$db->getfirst("SELECT email FROM `user` where `username` = '$send_user_value'");
    $mail->AddAddress("$send_user_value", "$username_email[email]");//收件人地址,可以替换成任何想要接收邮件的email信箱,格式是AddAddress("收件人email","收件人姓名")
    //showMsg("$send_title");
    $mail->Subject = "=?GB2312?B?".base64_encode("$send_title")."?="; //邮件标题
    $mail->Body = $send_text; //邮件内容
    //$mail->AltBody = "This is the body in plain text for non-HTML mail clients"; //附加信息,可以省略 if (!$mail->Send())
    {
                   $success = false ;
                   $error .= $send_user_value.',';
    }
    // Clear all addresses and attachments for next loop
    $mail->ClearAddresses();
    $mail->ClearAttachments(); echo "<script language=\"JavaScript\">\n";
    echo "      updateProgress(\"正在发送给:“$send_user_value” ....\", ";
         echo min($width, intval($progress));
         echo ");\n";
    echo "</script>\n"; ob_flush();
    flush();    //将输出发送给客户端浏览器,使其可以立即执行服务器端输出的 JavaScript 程序。
    $progress += $pix; }
    if ($success){
      echo "<script language=\"JavaScript\">updateProgress(\"发送完成!\", $width);</script>";
      ob_flush();
      flush();
          showMsg_noheader('已发送!','supermail.php');}
    else {
    showMsg_noheader("以下同志没有成功发送:$error",'supermail.php');
    }
    }
      

  3.   

    呵,就是让php发个邮箱就ob_flush(); flush(); 一下我在我的apache里都没事的,但是iis那边就不行??
      

  4.   

    Several servers, especially on Win32, will still buffer the output from your script until it terminates before transmitting the results to the browser. 
      

  5.   


    部分服务器,特别是Win32,仍会缓冲脚本的输出,直到脚本结束才发送到浏览器。看样子还是iis和php的兼容问题吧,我记得asp下就没问题
      

  6.   

    遇到同样问题,网上查到的原因为:
    php.ini
    output_buffering = 4096一些Web服务器的output_buffering默认是4069字符或者更大,即输出内容必须达到4069字符服务器才会flush刷新输出缓冲,为了确保flush有效,最好在ob_flush()函数前有以下语句:
    print str_repeat(" ", 4096);
    以确保到达output_buffering值。