Warning: Cannot modify header information - headers already sent by..... 정보
Warning: Cannot modify header information - headers already sent by.....본문
Warning: Cannot modify header information - headers already sent by.....
오류가 나서 해결 방법을 열심히 찾아 보았습니다.
utf-8 로 컨버팅해서 저장시
메모장으로 열어 저장하면 보이지 않은 기호를 파일의 헤더에 포함해서 생기는 현상이라는 답변을 얻었는데요
메모장, 울트라에디터 모두 그런 현상이 생긴다고에서 에디트플러스 사용중이기 합니다만,
혹시 다른 해결 방법은 없을까요?
댓글 전체

답변감사합니다.
euc-kr 에서는 ob_start(); 사용하면 문제는 없는데 utf-8 에서가 문제 인것 같습니다.
utf-8 를 사용중이라서요-.-
euc-kr 에서는 ob_start(); 사용하면 문제는 없는데 utf-8 에서가 문제 인것 같습니다.
utf-8 를 사용중이라서요-.-

utf-8에서 불러올 파일의 맨앞에 ob_start(); 넣어주니 해결 되네요. 갑자기 에러메세지 떠서 당황했다는..
utf-8로 저장하면 눈에 보이지 않는 문자들이 저장되어서 발생한다고 합니다.
해결책
Sometimes programmers want to change some of the header values. For example, if the PHP if generating XML output, the Content-Type should be changed to reflect this. Another common example is in redirecting the user’s browser to a different web page using the Location header element as described in this Tech-Recipe.
The header must come first in the response from a web server and is separated from the body by one blank line. The reason this error occurs is that some part of the body of the web page has been sent to the user already when a request is made to set a header value. Because PHP simplifies many things for you, the problem may be hiding in plain site. Here are some guidelines for finding the problem:
1) Find the header() statement that is causing the problem. The error must be at or before this line.
2) Look for any statements that could send output to the user before this header statement. If you find one or more, find some way to move the header statement before them. Complex conditional statements may complicate the issue, but they may also help solve the problem. Consider a conditional expression at the top of the PHP script that determines the header value as early as possible and sets it there.
3) Make sure there is no white space outside of the php start and end tags. While a blank line before the <?php start tag may look innocent, when processed by PHP, it will turn into an echo statement printing out a blank line. This is a common culprit.
UTF-8로 저장시 발생하는 3번 문제
This had me pulling my hair out for hours today.
I had all my php code before the HEAD without any whitespace. (you can't imagine how many times I pressed the delete key trying to get rid of white space that wasn't there :)
Anway, the culprit was that Dreamweaver saved the .php file as as a UTF-8 format file (I had renamed it from a UTF .html file .. so it's really my fault).
When a .php file is saved as UTF it inserts a
line break before everything, but it will be invisible in Dreamweaver.
What you have to do is open the .php file in notepad, and 'Save as' ANSI.
해결책
Sometimes programmers want to change some of the header values. For example, if the PHP if generating XML output, the Content-Type should be changed to reflect this. Another common example is in redirecting the user’s browser to a different web page using the Location header element as described in this Tech-Recipe.
The header must come first in the response from a web server and is separated from the body by one blank line. The reason this error occurs is that some part of the body of the web page has been sent to the user already when a request is made to set a header value. Because PHP simplifies many things for you, the problem may be hiding in plain site. Here are some guidelines for finding the problem:
1) Find the header() statement that is causing the problem. The error must be at or before this line.
2) Look for any statements that could send output to the user before this header statement. If you find one or more, find some way to move the header statement before them. Complex conditional statements may complicate the issue, but they may also help solve the problem. Consider a conditional expression at the top of the PHP script that determines the header value as early as possible and sets it there.
3) Make sure there is no white space outside of the php start and end tags. While a blank line before the <?php start tag may look innocent, when processed by PHP, it will turn into an echo statement printing out a blank line. This is a common culprit.
UTF-8로 저장시 발생하는 3번 문제
This had me pulling my hair out for hours today.
I had all my php code before the HEAD without any whitespace. (you can't imagine how many times I pressed the delete key trying to get rid of white space that wasn't there :)
Anway, the culprit was that Dreamweaver saved the .php file as as a UTF-8 format file (I had renamed it from a UTF .html file .. so it's really my fault).
When a .php file is saved as UTF it inserts a
line break before everything, but it will be invisible in Dreamweaver.
What you have to do is open the .php file in notepad, and 'Save as' ANSI.

저도 고생하다 해결이요 에디터플러스를 사용할 경우 도구-기본설정에서 utf-8 식별기호: 에서 항상 식별기호 제거 라고 하면 해결됩니다.
에디터플러스에 그런게 없는데요. 버전 3.20 ..