PHP
2014.06.02 14:27

Header for XML content in PHP file

조회 수 11535 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

+ - Up Down Comment Print
?

단축키

Prev이전 문서

Next다음 문서

+ - Up Down Comment Print
If you output XML content from PHP file, you need to set content-type header, so that your browser know that you are going to output XML content from PHP file instead of default content-type header (text/html).
File: php_file.php
<?php
header ("Content-Type:text/xml");
?>
<your_xml_content>
</your_xml_content>
You may know, no output (no html, echo, space etc) can occur before "header()" for header being sent to browser.

Content-type header tells browser how to handle the content. For example, if there is media file then browser will give you an option to use another application if it cannot handle that content. For *.mp3 file, it may ask you to use any applications installed on your computer that is associated with mp3 or it will tell you to download the content.
text/xml file is treated as us-ascii file if there is no charset specified. So, if your charset is different then specify that in the header as below.

Update:

header('Content-Type: application/xml; charset=utf-8');

application/xml with charset can be good, if you are preparing for any application to consume the xml file. With charset specified, there should not be any problem with any of the format.


Dreamy의 코드 스크랩

내가 모으고 내가 보는

List of Articles
번호 분류 제목 날짜 조회 수 추천 수
206 Pi [Arduino] 아두이노 나노 Arduino Nano Spec 1 file 2016.09.07 20514 0
205 C# [C#] (System.Collections.Generic) ArrayList 2012.05.23 15586 0
204 MFC [Collection] ArrayList 예제 2017.01.25 6990 0
203 MFC [Collection] CArray Class 사용법 2017.01.25 16257 0
202 MFC [Collection] CList 템플릿 클래스 사용하기 2010.06.24 47192 0
201 MFC [Collection] CMap 템플릿 클래스 사용하기 2010.06.23 50797 0
200 HTML5 [CSS] 선택자(Selector)의 이해 2017.12.29 10178 0
199 MFC [C] Unicode 사용에 대하여 2006.04.14 47443 0
198 Android [GIT 사용법] Dreamy의 요약 2 secret 2012.04.20 158 0
197 Android [GIT 사용법] Git Log 활용하기 2012.05.08 13214 0
196 Android [GIT 사용법] Git Tutorial 2011.12.26 96980 0
195 Android [GIT 사용법] 다른 branch와의 차이점 찾아보기 2012.08.16 22054 0
194 Android [GIT 사용법] 초보자가 알아두면 좋을 명령어 정리 1 2011.12.26 66952 0
193 Android [Git] git add 취소하기, git commit 취소하기, git push 취소하기 2021.09.30 5932 0
192 Android [GIT] git stash 사용하기 2012.10.22 31502 0
목록
Board Pagination ‹ Prev 1 ... 16 17 18 19 20 21 22 23 24 25 ... 34 Next ›
/ 34

나눔글꼴 설치 안내


이 PC에는 나눔글꼴이 설치되어 있지 않습니다.

이 사이트를 나눔글꼴로 보기 위해서는
나눔글꼴을 설치해야 합니다.

설치 취소

Designed by sketchbooks.co.kr / sketchbook5 board skin

Sketchbook5, 스케치북5

Sketchbook5, 스케치북5

Sketchbook5, 스케치북5

Sketchbook5, 스케치북5