http://blog.naver.com/nadarim/70108733705
PHP 의 header() 함수는 HTTP 헤더를 송신하기 위해서 사용된다.
…
void header(string $string, [, bool $replace = true [, int $http_response_code ]])
string : HTTP 상태코드 또는 리다이렉트할 문자열
replace : 헤더를 바꿀지 또는 같은 형식의 두번째 헤더를 추가할지 결정
http_response_code : HTTP response 코드를 강제로 지정
…
1. HTTP 상태코드 표시
header(“HTTP/1.0 404 Not Found”);
…
2. 리다이렉트
header(“Location:http://ksprg.cafe24.com”);
…
3. 캐시 사용 안함
header(“Cache-Control:no-cache”);
header(“Pragma:no-cache”);
or
header(“Expires: Mon, 20 Jul 2011 07: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”);
…
4. 파일 다운로드
header(“Content-type: application/xls”);
header(“Content-Disposition: attachment; filename=”test.xls”);
readfile(“org.xls”); // 원본 엑셀파일을 읽어 들인다.
…
5. 80포트로 들어온 요청을 다른 포트로 보내기
if($_SERVER["SERVER_PORT"] == “80″){
header(“Location: http://ksprg.cafe24.com:8080/”);
}
…
6. 문자셋을 utf-8로 변경
header(“Content-Type:text/html;charset=UTF-8″);
[출처] [PHP] header() 예제|작성자 밍밍
댓글 없음:
댓글 쓰기