Php XML分析错误:Twilio中文档元素后出现垃圾邮件

Php XML分析错误:Twilio中文档元素后出现垃圾邮件,php,xml,twilio,Php,Xml,Twilio,我正在运行下面的代码,它显示了这个错误。有人能告诉我为什么我的xml有问题吗?当我在浏览器中运行此操作时,我得到: XML Parsing Error: junk after document element 当我通过Twilio运行此命令时,我得到以下错误 parserMessage Error on line 2 of document : Content is not allowed in prolog. <?php header("content-type: t

我正在运行下面的代码,它显示了这个错误。有人能告诉我为什么我的xml有问题吗?当我在浏览器中运行此操作时,我得到:

XML Parsing Error: junk after document element
当我通过Twilio运行此命令时,我得到以下错误

parserMessage    Error on line 2 of document : Content is not allowed in prolog.

<?php

    header("content-type: text/xml");
      echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
    require "twilio-php-latest/Services/Twilio.php";

        /* Set our AccountSid and AuthToken */
    $AccountSid = "xxxxx";
    $AuthToken = "xxxx";

    include 'db.php';
    $caller=$_REQUEST['From'];
    /* Instantiate a new Twilio Rest Client */
    $client = new Services_Twilio($AccountSid, $AuthToken);

    $from= "+17864310795";
    $student_number=substr($caller,1);
        $db = new PDO("mysql:host=localhost;dbname=xxxx","xxxx","xxxx");
    $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $studentData=getSingleStudentData($db,$student_number);
    foreach($studentData as $key=>$val)
    {
        $student_id=$val['student_id'];
        $phone=$val['phone_number'];
        $status=$val['status'];
        echo $student_id;
        // find out last call successfully completed by the student
        if($status==1)
        {
            $progress = getLastActivity($db,$student_id);
X
X
X
echo "done with initialize<br/>";
            $server= "http://sample.com";


        try {
            $to = '+' . $phone;            
            echo $phone;
            $questions_id_url='questions_id_0='.$questions_id[0].'&questions_id_1='.$questions_id[1].'&questions_id_2='.$questions_id[2];
            $questions_file_url='questions_file_0='.$questions_file[0].'&questions_file_1='.$questions_file[1].'&questions_file_2='.$questions_file[2];
            $url = $server.'/startCall.php?call_id='.$call_id.'&phone='.$phone.'&'.$questions_id_url.'&'.$questions_file_url.'&student_id='.$student_id.'&story='
            .$story.'&story_id='.$story_id.'&call_number='.$call_number.'&question_number=0&count_english=0&count_hindi=0&insert_receivecall=0';
            echo "here"."-----".$url;
            $client->account->calls->create(
            "+17864310795",
            $to,
            $url,
            array(
            'Method' => "GET",
            'FallbackMethod' => "GET",
            'StatusCallbackMethod' => "GET",
            'Record' => "false",
            ));
        } catch (Exception $e) {
            // log error
        }
        }
    }
?>
<Response>
     <Reject reason="busy"/>
</Response> 
文档第2行的parserMessage错误:prolog中不允许有内容。 $val) { $student_id=$val['student_id']; $phone=$val['phone_number']; $status=$val['status']; echo$student\u id; //查找学生成功完成的最后一次呼叫 如果($status==1) { $progress=getLastActivity($db,$student\u id); X X X echo“完成初始化
”; $server=”http://sample.com"; 试一试{ $to='+'.$phone; 回声$电话; $questions\u id\u url='questions\u id\u 0='.$questions\u id[0].&questions\u id\u 1='.$questions\u id[1].&questions\u id\u 2='.$questions\u id[2]; $questions\u file\u url='questions\u file\u 0='.$questions\u file[0].&questions\u file\u 1='.$questions\u file[1].&questions\u file\u 2='.$questions\u file[2]; $url=$server./startCall.php?call_id='.$call_id.&phone='.$phone.&'.$questions_id_url.&'.$questions_file_url.&student_id='.$student_id.&story=' .$story.&story\u id='.$story\u id.&call\u number='.$call\u number.&question\u number=0&count\u english=0&count\u hindi=0&insert\u receivecall=0'; 回显“here”。“…”$url; $client->account->calls->create( "+17864310795", 美元至, $url, 排列( '方法'=>“获取”, '回退方法'=>“获取”, “StatusCallbackMethod”=>“GET”, '记录'=>“错误”, )); }捕获(例外$e){ //日志错误 } } } ?>
我已经尝试了所有的方法,希望能在这里发现错误

我认为您的问题在于,您在脚本中推出的不仅仅是XML。首先,将内容类型设置为XML并
echo
ing XML声明,然后开始
echo
调试命令,这些命令不是有效的XML,因此解析器会抛出错误

因此,首先,我将注释掉或删除脚本中任何
echo
s非XML内容的内容


如果有帮助,请告诉我。

这里是Twilio开发者福音传道者

我认为您的问题在于,您在脚本中推出的不仅仅是XML。首先,将内容类型设置为XML并
echo
ing XML声明,然后开始
echo
调试命令,这些命令不是有效的XML,因此解析器会抛出错误

因此,首先,我将注释掉或删除脚本中任何
echo
s非XML内容的内容


如果有帮助,请告诉我。

这里是Twilio开发者福音传道者

我认为您的问题在于,您在脚本中推出的不仅仅是XML。首先,将内容类型设置为XML并
echo
ing XML声明,然后开始
echo
调试命令,这些命令不是有效的XML,因此解析器会抛出错误

因此,首先,我将注释掉或删除脚本中任何
echo
s非XML内容的内容


如果有帮助,请告诉我。

这里是Twilio开发者福音传道者

我认为您的问题在于,您在脚本中推出的不仅仅是XML。首先,将内容类型设置为XML并
echo
ing XML声明,然后开始
echo
调试命令,这些命令不是有效的XML,因此解析器会抛出错误

因此,首先,我将注释掉或删除脚本中任何
echo
s非XML内容的内容

如果有帮助,请告诉我