php无标题文本


php no headers text

我已经编写了一个小的php脚本来为我处理解压缩。我可以从任何其他脚本中调用它,在我的情况下,从我拥有的perl脚本中调用,只需传递相关的文件名和目标目录。我的问题是,我想取回文件名以确认成功,但我无法让php打印出纯文本。它总是打印回标题。我可以让php在没有标题的情况下打印吗?尝试了header_remove,但它不起作用。

    <?php
    header_remove();
    if (!headers_sent()) {   foreach (headers_list() as $header)     header_remove        ($header); } 
    require("dUnzip2.inc.php");
    $Path = $_GET["path"];
    $save_to = $_GET["save_to"];
    $filename = $_GET["filename"];
    $zip_file = "$Path/$filename";
    $zip = new dUnzip2("$zip_file");
    $zip->debug = 0;
    $zip->unzipAll("$save_to");
    unlink("$Path/$filename");
    echo "$filename was uploaded and unpacked.";
    ?>

我从脚本中得到的回应是:

HTTP/1.1 200 OK
Connection: close
Date: Thu, 19 Jul 2012 20:40:04 GMT
Server: Nginx / Varnish
Content-Length: 38
Content-Type: text/html
Client-Date: Thu, 19 Jul 2012 20:40:04 GMT
Client-Peer: 66.86.255.11:80
Client-Response-Num:
Foo.zip was uploaded and unpacked. 

我希望它只是:

Foo.zip was uploaded and unpacked. 

编辑:已解决我用

    my $response = $ua->request($req)->as_string;

我应该在什么时候使用

    my $response = $ua->request($req)->content;

在我的PERL脚本中,谢谢你,我一直在看任何东西,但我需要看的地方。

这些标头来自您的服务器,例如HTTP版本和状态代码是HTTP规范的一部分。在客户端,您可以通过读取第一个空行来跳过标题。

生成if,如:

if ( strpos( 'Foo.zip was uploaded', $return) !== false ) {
    echo 'Foo.zip was uploaded and unpacked';
}