<?php
header("Content-type: text/xml");
$names = array (
"John Smith", "John Jones", "Jane Smith", "Jane Tillman",
"Abraham Lincoln", "Sally Johnson", "Kilgore Trout",
"Bob Atkinson","Joe Cool", "Dorothy Barnes",
"Elizabeth Carlson", "Frank Dixon", "Gertrude East",
"Harvey Frank", "Inigo Montoya", "Jeff Austin",
"Lynn Arlington", "Michael Washington", "Nancy West" );
if (!$query) {
$query=$_GET['query'];
}
echo "<?xml version=\"1.0\" ?>\n";
echo "<names>\n";
while (list($k,$v)=each($names)) {
if (stristr($v,$query)) {
echo "<name>$v</name>\n";
}
}
echo "</names>\n";
?>
如您所见,此 PHP 只是在数组中查找名称。
我将此 php 文件放在我的 xampp 根目录中,然后在浏览器中键入 search.php?query=John,然后它告诉我
此页面包含以下错误:第 2 行第 1 列的错误:文档末尾的额外内容下面是第一个错误之前的页面渲染。
怎么了?