Using PHP script to fill in XML

2019-09-01 19:44发布

we are all familiar with "embedding" PHP scripts in HTML pages to do tasks like displaying form results, but how can that be done in a way that displays XML?

For example, if I wrote:

<?xml version='1.0' ?>
<Response>
  <?php
        $body = $_GET['Body'];
        $fromPh = $_GET['From'];
        echo "<Msg>Your number is: $fromPh, and you typed: $body.</Msg>"
  ?>
</Response>

I get a message that states "parse error, unexpected T_STRING on line 1". Any help or tutorials would be appreciated.

标签: php xml forms
7条回答
看我几分像从前
2楼-- · 2019-09-01 20:07
function genOutput() {
$output = header("Content-type: text/xml");
$output.= "<container>\n";
$output.= "<title>".$title."</title>\n";
$output.= "<text>".$text."</text>\n";
$output.="</container>\n";
return $output;
}
查看更多
登录 后发表回答