PHP header 的7種用法

2022-07-13 13:36:08 字數 1649 閱讀 5965

1. 跳轉頁面

1header('location:'.$url);//location和":"之間無空格。

2. 宣告content-type

1header('content-type:text/html;charset=utf-8');

3. 返回response狀態碼

4. 在某個時間後執行跳轉

1header('refresh: 10; url=');  //10s後跳轉。

5. 控制瀏覽器快取12

34header("expires: mon, 26 jul 1997 05:00:00 gmt");

header("last-modified: ".gmdate("d, d m y h:i:s") ."gmt");

header("cache-control: no-cache, must-revalidate");

header("pragma: no-cache");

6. . 執行http驗證12

34header();//設定內容型別

header('content-disposition: attachment; filename="example.zip"');//設定mime使用者作為附件

header('content-transfer-encoding: binary');//設定傳輸方式

header('content-length: '.filesize('example.zip'));//設定內容長度

PHP header 的7種用法

1.跳轉頁面header location url location和 之間無空格。2.宣告content typeheader content type text html charset utf 8 3.返回response狀態碼header http 1.1 404not found 4.在某...

PHP header 的7種用法

這篇文章介紹的內容是關於php header 的7種用法 有著一定的參考價值,現在分享給大家,有需要的朋友可以參考一下 1.跳轉頁面 header location url location和 之間無空格。2.宣告content type header content type text html ...

PHP header 的幾種用法

php header 的幾種用法,你知道幾種?跳轉頁面 header location url location和 之間無空格。2.宣告content type header content type text html charset utf 8 3.返回response狀態碼 4.在某個時間後執...