Use two different headers for two different outputs on the same call

0

At some point, I need to generate XLS files on my system, and use the following header for outputs:

header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="' . $name[$a] . '.xls"');
header('Cache-Control: max-age=0');

But, I do not use the answer of this method, I need the answer of another method that should return a json, I'm trying:

header('Content-type:application/json;charset=utf-8');
echo json_encode($response);

I define this header after having called the previous headers ( 'vnd.ms-excel' ) and used them, but the answer does not take that second definition, it always returns me with the coding for 'vnd.ms-excel' .

How to use a header to generate a .XLS and a second to return a json on the same call?

    
asked by anonymous 25.09.2017 / 18:18

0 answers