我想用PHP导出CSV。但不是打印结果,而是在生成的CSV文件中打印Resource id #26
。如果我从结尾中删除退出,它会打印出我的整个HTML页面内容。我的代码是...导出CSV打印HTML
if (isset($_REQUEST['download']) && ($_REQUEST['download'] == "yes")) {
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=link_point_report.csv');
$output = fopen('php://memory', 'w+');
fputcsv($output, array('Member Id', 'Customer Name', 'Customer Email'));
$customerListAll = $oAdmFun->linkpoint_check_customer('', '');
$oAdmFun->pr($customerListAll, true);
// if (count($customerListAll) > 0) {
// for ($c = 0; $c < count($customerListAll); $c++) {
// fputcsv($output, array('Sankalp', 'Sankalp', 'Sankalp'));
// }
// }
ob_clean();
flush();
exit($output);
}
'exit($ output);'应该按预期打印'资源ID#xx'。那么你的问题是什么? –
我想虚拟地创建一个文件,编写它并提供它下载,以便文件不应该保存在服务器上。 – Sankalp
像这样http://php.net/manual/en/function.fputcsv.php#106583? –