2
The code for download that works at localhost is but live at hostgather server it throughs error 


ob_get_clean();
    header("Content-type: text/x-csv"); # DECLARING FILE TYPE
    header("Content-Transfer-Encoding: binary");
    header("Content-Disposition: attachment; filename=".$csv_file_name); # EXPORT GENERATED CSV FILE
    header("Pragma: no-cache");
    header("Expires: 0");

    echo $fields;
    exit;

错误是

警告:无法修改标头信息 - 标头已由 /home/londoner/public_html/pkfones 中的(输出开始于 /home/londoner/public_html/pkfones.com/pinquest/wp-admin/includes/template.php:1679)发送。 com/pinquest/wp-content/plugins/wp-gamesize/setgamesize_admin.php 在第 131 行

4

1 回答 1

1

确保您在ob_start()代码执行的开始(或非常接近)时调用。这将缓冲您的所有输出并允许您随时发送标头。您可以将它放在您的functions.php 的最顶部。

这适用于您的本地而不是实时的原因可能是服务器配置的差异,默认情况下您在本地缓冲但不是实时。这是确保您的开发和生产环境尽可能相似的一个很好的理由。

于 2014-06-16T20:12:49.827 回答