IT/php

php header — HTTP 헤더 보내기

조원태 2016. 12. 19. 20:26
반응형

header —  HTTP 헤더 보내기

 

설명 ¶

 

void header ( string $string [, bool $replace = true [, int $http_response_code ]] )

header ()는 원시 HTTP 헤더를 보내는 데 사용됩니다. HTTP 헤더에 대한 자세한 내용은»HTTP / 1.1 사양을 참조하십시오.

 

 

header ()는 일반적인 HTML 태그, 파일의 빈 줄 또는 PHP에서 실제 출력을 보내기 전에 호출해야한다는 것을 기억하십시오. include, require, 함수 또는 다른 파일 액세스 함수로 코드를 읽고 header ()가 호출되기 전에 공백이나 빈 줄이 출력되는 것은 매우 일반적인 오류입니다. 단일 PHP / HTML 파일을 사용할 때도 같은 문제가 발생합니다.

<html>

<?php

/* This will give an error. Note the output

 * above, which is before the header() call */

header('Location: http://www.example.com/');

exit;

?>

반응형