【发布时间】:2011-07-29 21:07:50
【问题描述】:
如何编辑我在下面使用的代码来保存生成的文件而不是将其打印在屏幕上?
<?php
header("Content-type: text/xml");
$linkID = mysql_connect($host, $user, $pass) or die("Could not connect to host.");
mysql_select_db($database, $linkID) or die("Could not find database.");
$query = "";
$resultID = mysql_query($query, $linkID) or die("Data not found.");
$xml_output = "<?xml version=\"1.0\"?>\n";
$xml_output .= "<products>\n";
for($x = 0 ; $x < mysql_num_rows($resultID) ; $x++){
$row = mysql_fetch_assoc($resultID);
$xml_output .= "\t<product>\n";
.
.
.
$xml_output .= "\t</product>\n";
}
$xml_output .= "</products>";
echo $xml_output;
?>
【问题讨论】:
-
如果您的意思是保存到本地文件,请参见例如tizag.com/phpT/filewrite.php