Warning: Cannot modify header information – How to resolve this issue?

What is the wrong with this code. I am always getting the error like:

Warning: Cannot modify header information – headers already sent by
(output started at
/home/krishnas/Documents/wordpress/wp-admin/menu-header.php:91) in
/home/krishnas/Documents/wordpress/wp-includes/pluggable.php on line
866

$upload_dir = wp_upload_dir();
        $basedir = $upload_dir['basedir'];
        $baseurl = $upload_dir['baseurl'];
        $filename = "products_".date('YmdHis').".xls";
        $fp = fopen($basedir.'/'.$filename,'wr');
        fwrite($fp,$content_final);
        $excell_file = $baseurl.'/'.$filename;
        //echo $basedir;
        //echo $baseurl;
        //exit;
        //exit;
        wp_redirect($excell_file);exit;}}?>

Related posts

Leave a Reply

2 comments

  1. Make sure there is no blank space or any extra character after ?> of PHP. It’s seen that such errors are usually causes by extra characters after ?> at the end of file. Please check both the files mentioned in the error code. Let us know if this resolves your error.