PHP 中的 header() 函式


header() 函式會向客戶端傳送原始 HTTP 頭。

語法

header(string,replace,resp_code)

引數

  • string − 要傳送的頭字串。

  • replace − 指明是替換前一個頭還是新增第二個頭。

  • resp_code − 強制 HTTP 響應程式碼為指定的值

返回值

header() 函式不返回任何東西。

示例

下面是儲存已生成 PDF 的示例 −

<?php
   header("Content-type:application/pdf");
   header("Content-Disposition:attachment;filename=output.pdf'");
   readfile("demo.pdf");
?>

下載的檔案為“output.pdf”,而輸入為“demo.pdf”。

更新時間: 30-Jul-2019

383 次瀏覽

開啟你的 職業生涯

完成課程,獲得認證

開始你的學習之旅
廣告
© . All rights reserved.