Php 使用文件获取内容时文件中的最后一个未知符号

Php 使用文件获取内容时文件中的最后一个未知符号,php,curl,file-get-contents,Php,Curl,File Get Contents,我有个小问题。当我通过file_get_contents获取页面时,未知符号与输出相关联,这会破坏XML结构 我怎样才能解决这个问题 代码: file_get_contents('https://emea2cps.adobeconnect.com/api/xml?action=login&login=EMAIL&password=PASSWORD'); $cookies = array(); foreach ($http_response_header

我有个小问题。当我通过file_get_contents获取页面时,未知符号与输出相关联,这会破坏XML结构

我怎样才能解决这个问题

代码

    file_get_contents('https://emea2cps.adobeconnect.com/api/xml?action=login&login=EMAIL&password=PASSWORD');

    $cookies = array();
    foreach ($http_response_header as $hdr) {
        if (preg_match('/^Set-Cookie:\s*([^;]+)/', $hdr, $matches)) {
            parse_str($matches[1], $tmp);
            $cookies += $tmp;
        }
    }

    //print_r($cookies);

    //echo "//////////////////";

    $cook=$cookies['BREEZESESSION'];
    echo $cook;

    $opts = array(
      'http'=>array(
        'method'=>'GET',
        'header'=>'Cookie: BREEZESESSION='.$cook.'\r\n',
      )
    );

    $context = stream_context_create($opts);
    echo "////////////////////////";
    // Open the file using the HTTP headers set above
    //$file = file_get_contents('http://www.example.com/', false, $context);
    $file1 = file_get_contents('https://meet77842937.adobeconnect.com/api/xml?action=report-my-meetings', false, $context);

    print_r($file1);

    $xml = new SimpleXMLElement($file1);
em2breezgwbhxopvpvknsux7////////////////////////sample1aksamaimeet77842937.adobeconnect.com/sample1/2014-02-28T06:15:00.000-08:002014-02-28T07:15:00.000-08:00true01:00:00.000sample2meet77842937.adobeconnect.com/sample2/2014-02-28T06:15:00.000-08:002014-02-28T07:15:00.000-08:00true01:00:00.000lastTtmeet77842937.adobeconnect.com/lastone/2014-02-28T15:30:00.000-08:002014-02-28T18:00:00.000-08:00false02:30:00.000�
输出

    file_get_contents('https://emea2cps.adobeconnect.com/api/xml?action=login&login=EMAIL&password=PASSWORD');

    $cookies = array();
    foreach ($http_response_header as $hdr) {
        if (preg_match('/^Set-Cookie:\s*([^;]+)/', $hdr, $matches)) {
            parse_str($matches[1], $tmp);
            $cookies += $tmp;
        }
    }

    //print_r($cookies);

    //echo "//////////////////";

    $cook=$cookies['BREEZESESSION'];
    echo $cook;

    $opts = array(
      'http'=>array(
        'method'=>'GET',
        'header'=>'Cookie: BREEZESESSION='.$cook.'\r\n',
      )
    );

    $context = stream_context_create($opts);
    echo "////////////////////////";
    // Open the file using the HTTP headers set above
    //$file = file_get_contents('http://www.example.com/', false, $context);
    $file1 = file_get_contents('https://meet77842937.adobeconnect.com/api/xml?action=report-my-meetings', false, $context);

    print_r($file1);

    $xml = new SimpleXMLElement($file1);
em2breezgwbhxopvpvknsux7////////////////////////sample1aksamaimeet77842937.adobeconnect.com/sample1/2014-02-28T06:15:00.000-08:002014-02-28T07:15:00.000-08:00true01:00:00.000sample2meet77842937.adobeconnect.com/sample2/2014-02-28T06:15:00.000-08:002014-02-28T07:15:00.000-08:00true01:00:00.000lastTtmeet77842937.adobeconnect.com/lastone/2014-02-28T15:30:00.000-08:002014-02-28T18:00:00.000-08:00false02:30:00.000�
看最后一个符号。它不能理想地存在


关于

请发布您的代码。如果您通过浏览器获取XML,它是否正确?@aebersold,是的,它是正确的。我现在发布。@aebersold,有什么想法吗?在标题中设置正确的编码。这看起来像是UTF-8/ISO编码问题。这是一个编码问题。