header 関数を使用してさまざまな HTTP ヘッダーを設定する php の例
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
リリース: 2016-07-25 09:04:39
-
- /**
- 説明: header 関数はさまざまな HTTP ヘッダーを設定します
- リンク: bbs.it-home.org
- 日付: 2013/2/24
- */
- //エンコーディングを定義する
- header( 'Content-Type: text/html;charset=utf-8 ');
-
- //Atom
- header ('コンテンツ タイプ: application/atom+xml');
-
- //CSS
- header('コンテンツ タイプ: text/css');
-
- //Javascript
- header('コンテンツ タイプ: text/javascript' );
-
- //JPEG 画像
- header('コンテンツ タイプ: image/jpeg');
-
- //JSON
- header('コンテンツ タイプ: application/json');コンテンツ タイプ: application/pdf');
-
- //RSS
- header('Content-Type: application/rss+xml; charset=ISO-8859-1');
-
- //テキスト (プレーン)
- header( 'コンテンツ タイプ: text/plain');
-
- //XML
- header('コンテンツ タイプ: text/xml');
-
- // ok
- header('HTTP/1.1 200 OK'); /404 ヘッダーを設定します:
- header('HTTP/1.1 404 Not Found');
-
- //永続的にリダイレクトされるアドレスを設定します
- header('HTTP/1.1 301 Moved Permanently');新しいアドレス
- header('Location: http://bbs.it-home.org/');
-
- //ファイルの遅延リダイレクト:
- header('Refresh: 10; url=http://bbs.it-home .org/');
- print '10 秒後にリダイレクトされます';
-
- //もちろん、HTML 構文を使用して実装することもできます
- //
- header('Content-Transfer-Encoding: binary');
- // 送信するファイルをロードします:
- readfile('example.zip');
-
- // 現在のドキュメントのキャッシュを無効にする
- header('Cache-Control: no-cache, no-store, max-age=0 、must-revalidate') ;
- header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // 過去の日付
- header('Pragma: no-cache');コンテンツタイプ:
- header( 'Content-Type: text/html; charset=iso-8859-1');
- header('Content-Type: text/html; charset=utf-8'); -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.1 401 Unauthorized')
- header('WWW-Authenticate: Basic realm="Top Secret"'); ;
- print 'ユーザーがキャンセルまたは';
- print '入力したログインデータが間違っている場合に表示されるテキスト';
- ?>
-
-
- コードをコピー
-
-
-
-
-
-
-
-
-
-
-
|
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
著者別の最新記事
-
2024-10-22 09:46:29
-
2024-10-13 13:53:41
-
2024-10-12 12:15:51
-
2024-10-11 22:47:31
-
2024-10-11 19:36:51
-
2024-10-11 15:50:41
-
2024-10-11 15:07:41
-
2024-10-11 14:21:21
-
2024-10-11 12:59:11
-
2024-10-11 12:17:31