test.php
<?php
$lineFeed = "\n";
$xml = '<?xml version="1.0" encoding="utf-8"?>' . $lineFeed;
$xml .= '<root>' . $lineFeed;
$xml .= '<description>' . $lineFeed;
$xml .= '<couponName>' . "1111" . '</couponName>' . $lineFeed;
$xml .= '<couponDescription>' . "222" . '</couponDescription>' . $lineFeed;
$xml .= '<quantity>' . "3333" . '</quantity>' . $lineFeed;
$xml .= '</description>' . $lineFeed;
$xml .= '<codes>' . $lineFeed;
$xml .= '<code>' . "codecode" . '</code>' . $lineFeed;
$xml .= '</codes>' . $lineFeed;
$xml .= '</root>' . $lineFeed;
header("Content-Type:text/xml charset=UTF-8");
header("Content-Disposition:attachment; filename=offer-coupon.xml");
header('Cache-Control:must-revalidate,post-check=0,pre-check=0');
header('Expires:0');
header('Pragma:public');
$name = "test.xml";
$fp = fopen("D:\\down\\".$name, "wt+");//fopen('php://output', 'D/down/test.xml');
fwrite($fp, $xml);
fclose($fp);
die();
网上的好多写法是这样的 好像是有错误吧 //fopen(‘php://output’, ‘D/down/test.xml’);
下载成功之后
bat文件处理
D:\php\php.exe -q D:\website\a.php
新建一个a.php
file_get_contents(‘http://localhost/test.php’)
相当于a文件是调取生成xml下载的过程