可能出錯的片段
foreach($result as $rs){
$o=$rs['title'];
header('Content-type: application/pdf');
// It will be called downloaded.pdf
header('Content-Disposition: attachment; filename="downloaded.pdf"');
// The PDF source is in original.pdf
readfile('original.pdf');
// We'll be outputting a PDF
``
Nginx error log 錯誤提示如下
請各位幫我解惑,謝謝
PHP Parse error: syntax error, unexpected ' header' (T_STRING) in /var/www/html/web/word/pdf.php on line 47" while reading response header from upstream, client
1.header 要放在輸出的最前面
像是
echo '123';
header(...); // <- 會報錯(不過好像有辦法繞過)
2.header放在回圈內欠妥,如同在討論中的ccutmis大大說的一樣