doudou32012 2010-04-01 20:20
浏览 39
已采纳

如何在PHP中禁用卷曲调试输出

I wrote a PHP CUrl Class, if i execute Methods which should return the Content, it returns at first the Headers and after that the Content. So i cant parse any XML Data. I need to Disable This Sample Output.

HTTP/1.1 200 OK
Date: Thu, 01 Apr 2010 20:11:58 GMT
Server: Apache/2.2.9 (Debian) PHP/5.2.6-1+lenny4 with Suhosin-Patch mod_ssl/2.2.9 OpenSSL/0.9.8g
X-Powered-By: PHP/5.2.6-1+lenny4
Set-Cookie: PHPSESSID=44beccf62f87546140d4a0bd24bd28b0; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Transfer-Encoding: chunked
Content-Type: application/xml

Here is The Curl Class

<?php

class Test_Curl
{
    protected $curl;
    protected $headers;
    protected $useragent;
    protected $url;
    protected $testkey;

    public function  __construct()
    {

    }

    public function setUseraget($useragent)
    {
        $this->useragent = $useragent;
        return $this;
    }

    public function setApiKey($key)
    {

        $this->billomatApiKey   = $key;
    }

    private function curlExecGeneral()
    {
        $result     = curl_exec($this->curl);
        curl_close($this->curl);
        return $result;
    }



    private function curlInitGeneral($request)
    {
        $this->curl = curl_init($request);
        curl_setopt($this->curl, CURLOPT_HEADER, true);
        curl_setopt($this->curl, CURLOPT_HTTPHEADER, array("X-testkey: ".$this->testkey, "Content-Type: application/xml"));
        curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, true);
    }

    public function get($request)
    {
        $this->curlInitGeneral($request);
        curl_setopt ($this->curl, CURLOPT_HTTPGET, true);
        return $this->curlExecGeneral();
    }

    public function post($request, $xml)
    {
        $this->curlInitGeneral($request);
        curl_setopt ($this->curl, CURLOPT_POST, true); //set the Requestmethod to POST
        curl_setopt ($this->curl, CURLOPT_POSTFIELDS, $xml); //add the xml data to the Request
        return $this->curlExecGeneral();
    }



}
?>
  • 写回答

1条回答 默认 最新

  • doubushi0031 2010-04-01 20:23
    关注

    See cURL options:

    curl_setopt($ch, CURLOPT_HEADER, 0);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 本题的答案是不是有问题
  • ¥15 关于#r语言#的问题:(svydesign)为什么在一个大的数据集中抽取了一个小数据集
  • ¥15 C++使用Gunplot
  • ¥15 这个电路是如何实现路灯控制器的,原理是什么,怎么求解灯亮起后熄灭的时间如图?
  • ¥15 matlab数字图像处理频率域滤波
  • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
  • ¥15 ELGamal和paillier计算效率谁快?
  • ¥15 蓝桥杯单片机第十三届第一场,整点继电器吸合,5s后断开出现了问题
  • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?
  • ¥15 Arcgis相交分析无法绘制一个或多个图形