Warning: Cannot modify header information - headers already sent by..... > 그누4 질문답변

그누4 질문답변

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기
기존 게시물은 열람만 가능합니다.

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 로 컨버팅해서 저장시
메모장으로 열어 저장하면 보이지 않은 기호를 파일의 헤더에 포함해서 생기는 현상이라는 답변을 얻었는데요

메모장, 울트라에디터 모두 그런 현상이 생긴다고에서 에디트플러스 사용중이기 합니다만,

혹시 다른 해결 방법은 없을까요?

댓글 전체

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.
전체 66,554 |RSS
그누4 질문답변 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1402호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT