php的header
A. php的header問題。
header('Status: 2342');前肯定能輸;
ob函數使用標准參考:
ob_start();
........
if ( something ){
ob_end_clean();
header("Location: yourlocation");
exit;
else{
..........
ob_flush(); //省略
要想header前輸修改php.ini文件
output_handler =mb_output_handler
或 output_handler =on
B. php中header() 有什麼用
header的用法
標頭 (header) 是伺服器以 HTTP 協義傳 HTML 資料到瀏覽器前所送出的字串,在標頭
與 HTML 文件之間尚需空一行分隔。有關 HTTP 的詳細說明,可以參 RFC 2068 官方文件
(http://www.w3.org/Protocols/rfc2068/rfc2068)。在 PHP 中送回 HTML 資料前,需先
傳完所有的標頭。
注意: 傳統的標頭一定包含下面三種標頭之一,並只能出現一次。
Content-Type: xxxx/yyyy
Location: xxxx:yyyy/zzzz
Status: nnn xxxxxx
在新的多型標頭規格 (Multipart MIME) 方可以出現二次以上。
使用範例
範例一: 本例使瀏覽器重定向到 PHP 的官方網站。
Header("Location: http://www.php.net";);
exit;
>?
範例二: 要使用者每次都能得到最新的資料,而不是 Proxy 或 cache 中的資料,可以使用下列的標頭
header("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");
>?
範例三: 讓使用者的瀏覽器出現找不到檔案的信息。
header("Status: 404 Not Found");
>?
範例四:讓使用者下載檔案。
header("Content-type: application/x-gzip");
header("Content-Disposition: attachment; filename=文件名\");
header("Content-Description: PHP3 Generated Data");
?>
header重定向 就等價於替用戶在地址欄輸入url
C. php設置網頁頭header參數有哪些
header(string,replace,http_response_code)
string 必需。規定要發送的報頭字元串。
replace 可選。指示該報頭是否替換之前的報頭,或添加第二個報頭。
默認是 true(替換)。false(允許相同類型的多個報頭)。
http_response_code 可選。把 HTTP 響應代碼強制為指定的值。(PHP 4 以及更高版本可用)
header("Content-type:text/html;charset=utf-8");
D. php的header 函數怎麼用
header就是伺服器向瀏覽器提交的http請求經常用來設置如何處理顯示的頁面,比如header(「Content-type:text/html;charset=utf8」);接下來要輸出的文本全當做html輸出並且編碼是utf8
E. php中的header(),不起作用。
php的header函數作用是給瀏覽器發送的HTTP連接請求頭中的內容定製,和頁面內<meta http-equiv="content-type" content="text/html;charset=gbk" />是兩回事。
header設置為image/ipeg的話,內容不是給人閱讀的文本,設定文字編碼作用不到圖片上文字,因為文字也是圖片,沒有編碼了。
軟體沒有問題。在圖片上寫一個GBK或者UTF8編碼的文字,似乎沒什麼意義?
如果要正常顯示,只要保證你所有的字元串都是UTF8就可以了。
F. php的header函數設置在哪
//ok
header(『HTTP/1.1200OK');
//設置一個404頭:
header(『HTTP/1.1404NotFound');
//設置地址被永久的重定向
header(『HTTP/1.1301MovedPermanently');
//轉到一個新地址
header(『Location:http://www.example.org/『);
//文件延遲轉向:
header(『Refresh:10;url=http://www.example.org/『);
print『';
//當然,也可以使用html語法實現
//<metahttp-equiv=」refresh」content=」10;http://www.example.org//>
//overrideX-Powered-By:PHP:
header(『X-Powered-By:PHP/4.4.0′);
header(『X-Powered-By:Brain/0.6b');
//文檔語言
header(『Content-language:en');
//告訴瀏覽器最後一次修改時間
$time=time()–60;//orfilemtime($fn),etc
header(『Last-Modified:『.gmdate(『D,dMYH:i:s',$time).'GMT');
//告訴瀏覽器文檔內容沒有發生改變
header(『HTTP/1.1304NotModified');
//設置內容長度
header(『Content-Length:1234′);
//設置為一個下載類型
header(『Content-Type:application/octet-stream');
header(『Content-Disposition:attachment;filename=」example.zip」『);
header(『Content-Transfer-Encoding:binary');
//loadthefiletosend:
readfile(『example.zip');
//對當前文檔禁用緩存
header(『Cache-Control:no-cache,no-store,max-age=0,must-revalidate');
header(『Expires:Mon,26Jul199705:00:00GMT');//Dateinthepast
header(『Pragma:no-cache');
//設置內容類型:
header(『Content-Type:text/html;charset=iso-8859-1′);
header(『Content-Type:text/html;charset=utf-8′);
header(『Content-Type:text/plain');//純文本格式
header(『Content-Type:image/jpeg');//JPG***
header(『Content-Type:application/zip');//ZIP文件
header(『Content-Type:application/pdf');//PDF文件
header(『Content-Type:audio/mpeg');//音頻文件
header(『Content-Type:application/x-shockw**e-flash');//Flash動畫
//顯示登陸對話框
header(『HTTP/1.1401Unauthorized');
header(『WWW-Authenticate:Basicrealm=」TopSecret」『);
print『『;
print『enterswronglogindata';
G. php中header()作用
header的用法
標頭 (header) 是伺服器以 HTTP 協義傳 HTML 資料到瀏覽器前所送出的字串,在標頭
與 HTML 文件之間尚需空一行分隔。有關 HTTP 的詳細說明,可以參 RFC 2068 官方文件
(http://www.w3.org/Protocols/rfc2068/rfc2068)。在 PHP 中送回 HTML 資料前,需先
傳完所有的標頭。
注意: 傳統的標頭一定包含下面三種標頭之一,並只能出現一次。
Content-Type: xxxx/yyyy
Location: xxxx:yyyy/zzzz
Status: nnn xxxxxx
在新的多型標頭規格 (Multipart MIME) 方可以出現二次以上。
使用範例
範例一: 本例使瀏覽器重定向到 PHP 的官方網站。
Header("Location: http://www.php.net";);
exit;
>?
範例二: 要使用者每次都能得到最新的資料,而不是 Proxy 或 cache 中的資料,可以使用下列的標頭
header("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");
>?
範例三: 讓使用者的瀏覽器出現找不到檔案的信息。
header("Status: 404 Not Found");
>?
範例四:讓使用者下載檔案。
header("Content-type: application/x-gzip");
header("Content-Disposition: attachment; filename=文件名\");
header("Content-Description: PHP3 Generated Data");
?>
header重定向 就等價於替用戶在地址欄輸入url
---------------------------------
//剛好找到比較詳細的資料!
H. php header 怎麼設置
PHP設置header示例:
<?php
//設置頁面編碼
header("Content-type:/text/html;charset=utf-8;");
//頁面重定向跳轉示例
header("location:index.php");
I. php中的header("Content-type: image/jpeg")是什麼意思
php裡面header是設定http協議標頭的函數。
HTTP協議是基於請求/響應範式的。一個客戶機與伺服器建立連接後,發送一個請求給伺服器。伺服器端返回響應,可以告知客戶端相關的信息。
header("Content-type: image/jpeg")表明請求頁面的內容是jpeg格式的圖像。