-3

我正在用PHP 中的 Twilio 服务开发一个小程序。这是我的 Twilio 侧代码:

<?php
    header("content-type: text/xml");
    echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
?>
<Response>
<?php
$currrentDate = date('Y-m-d', time());
$current = file_get_contents("1.txt");
$current .= "Caller (".$_REQUEST['From'].")";
file_put_contents("1.txt", $current);
$current .= " at ".date("m/d/y G:i:s", time())."<br/>";
file_put_contents("1.txt", $current);
?>
</Response>

这很好用,但是当我使用包含函数时它不起作用。我将 php 代码放入另一个名为“test.php”的 php 文件中。

<?php
    header("content-type: text/xml");
    echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
?>
<Response>
<?php
include("test.php");
?>
</Response>

这是我的 test.php 文件。

<?php
$currrentDate = date('Y-m-d', time());
$current = file_get_contents("1.txt");
$current .= "Caller (".$_REQUEST['From'].")";
file_put_contents("1.txt", $current);
$current .= " at ".date("m/d/y G:i:s", time())."<br/>";
file_put_contents("1.txt", $current);
?>

有人能告诉我为什么吗?谢谢!

4

1 回答 1

2

您正在发送标头和 xml 定义两次..

消除

<?php
    header("content-type: text/xml");
    echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
?>
<Response>

?>
</Response>

来自 test.php

于 2013-07-09T13:52:54.340 回答