「PHP学習」php開発でヘッダ(header)の基礎知識のまとめ

PHPコード:
<?php
header('HTTP/1.1 200 OK’);
header('HTTP/1.1 404 Not Found’);
header('HTTP/1.1 301 Moved Permanently’);
header('Location: http://www.arkgame.com/’);
header('Refresh: 10; url=http://www.arkgame.com/’);
header('X-Powered-By: PHP/6.0.0’);
header('Content-language: en’);
header('Content-Length: 1234’);
header('Last-Modified: '.gmdate('D, d M Y H:i:s’, $time).’ GMT’);
header('HTTP/1.1 304 Not Modified’);

###content type###
header('Content-Type: text/html; charset=utf-8’);
header('Content-Type: text/plain’);
header('Content-Type: image/jpeg’);
header('Content-Type: application/zip’); // ZIP
header('Content-Type: application/pdf’); // PD
header('Content-Type: audio/mpeg’);
header('Content-type: text/css’);
header('Content-type: text/javascript’);
header('Content-type: application/json’); //json
header('Content-type: application/pdf’); //pdf
header('Content-type: text/xml’); //xml
header('Content-Type: application/x-shockw**e-flash’); //Flash

######

###ダウンロードファイル###
header('Content-Type: application/octet-stream’);
header('Content-Disposition: attachment; filename="startnews24_dl.zip"');
header('Content-Transfer-Encoding: binary’);
readfile('test.zip’);
######

###ドキュメント禁止###
header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate’);
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT’);
######

###ログインダイアログ###
header('HTTP/1.1 401 Unauthorized’);
header('WWW-Authenticate: Basic realm="Top Secret"');
######

###xlsファイルのダウンロード###
header('Content-Disposition: attachment; filename=it_startnews24.xlsx’);
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet’);
header('Content-Length: '.filesize('./startnews24_tt.xls’));
header('Content-Transfer-Encoding: binary’);
header('Cache-Control: must-revalidate’);
header('Pragma: public’);
readfile('./startnews24_tt.xls’);
######

?>

PHP

Posted by arkgame