用PHP在浏览器中打开PDF
我正在做:用PHP在浏览器中打开PDF,php,html,pdf,Php,Html,Pdf,我正在做: header('Content-type: application/pdf'); header('Content-Disposition: inline; filename="the.pdf"'); header('Content-Length: ' . filesize($file)); @readfile($file); 而且效果很好。PDF将在浏览器中打开 我可以先做一个if-then-else吗?我试过了,我得到了原始PDF %PDF-1.2 9 0 obj <<
header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="the.pdf"');
header('Content-Length: ' . filesize($file));
@readfile($file);
而且效果很好。PDF将在浏览器中打开
我可以先做一个if-then-else吗?我试过了,我得到了原始PDF
%PDF-1.2 9 0 obj << /Type/Font /Subtype/Type1 /Name/F1 /FontDescriptor 8 0
%PDF-1.2 9 0 obj确保if-then-else块中的代码不会导致任何内容输出到页面
一旦输出了某些内容,对header()
的调用将不再起作用。如果您准确地发布了if-then-else代码,这将非常有用。我猜在输出标题之前,您会有一些空白输出。您能给出一些示例代码吗?您是对的。前空格