怎么在不改变服务器配置的情况下用php将header里Connection设置为close啊
而且我用header(“Connection:close”)不管用啊

解决方案 »

  1.   

    <?php
    header("Content-Length: 0");
    header("Connection: close");
    flush();
    ?>
      

  2.   

    不行啊,我要在页面里啊加数据啊,Content-Length不能设为0,而且不管用啊
      

  3.   

    <?php
        $fp = fopen('/tmp/chinese_test.log', 'a');
        fwrite($fp, "[" . strftime("%Y/%m/%d %H:%M:%S") . "] " . $_SERVER['QUERY_STRING'] . "\n");
        fclose($fp);
    header("Connection: close");
        header("Content-Type: application/xml");
        if (!array_key_exists('method', $_GET) or ($_GET['method'] != "callbacks.payment")) {
            header("invocation-error: 3");
            echo("<?xml version=\"1.0\" encoding=\"UTF-8\"?><error_response><error_code>3</error_code></error_response>");
        } elseif (!array_key_exists('sig', $_GET) or ($_GET['sig'] == "wrong")) {
            header("invocation-error: 103");
            echo("<?xml version=\"1.0\" encoding=\"UTF-8\"?><error_response><error_code>103</error_code></error_response>");
        } elseif (array_key_exists('exception', $_GET)) {
            header("invocation-error: 1");
            echo("<?xml version=\"1.0\" encoding=\"UTF-8\"?><error_response><error_code>1</error_code></error_response>");
        } else {
            echo("<?xml version=\"1.0\" encoding=\"UTF-8\"?><callbacks_payment_response>true</callbacks_payment_response>");
        }
    ?>
    这是我的代码
      

  4.   

    知道你要输出.专门留了个 flush()header("Connection: close\r\n");
    header("Content-Encoding: none\r\n");
    ob_start();
    echo ('这是处理和输出的内容');
    $size = ob_get_length();
    header("Content-Length: $size");
    ob_end_flush();
    flush();
      

  5.   

    那你想要啥呢?浏览器难道没有接到Connection: close ?自己鼓捣吧.
      

  6.   

    浏览器还是Connection: keep-alive
      

  7.   

    不知道你那什么浏览器.我这看的就是close.
      

  8.   

    不是啊,我在本地wamp测试也是Connection:close啊,但是放在ngix服务器上就不行了啊