PHP
2014.06.02 14:27

Header for XML content in PHP file

조회 수 11534 댓글 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 개념 Android CTS(Android Compatibility Test Suite) 2012.02.15 17408 0
205 LINUX Samba 설치 및 설정 방법 2013.03.29 17419 0
204 개념 DLNA(Digital Living Network Alliance) file 2012.01.27 17459 0
203 Android 안드로이드에서 Database를 다뤄보자 2015.03.03 17486 0
202 Pi [아두이노] 포트를 직접 억세스하기 (Direct Port Manipulation in Arduino) 1 2017.07.24 17583 0
201 C 정규식 테스트 사이트 2012.09.20 17808 0
200 C# 인터넷 연결상태 확인 2013.02.01 17874 0
199 Android 자바 call stack을 임의로 보는 방법 2012.09.05 17971 0
198 LINUX mc(Midnight Commander) 사용법 2 2014.04.07 18051 0
197 JAVA java JSON Parsing 예제들 2017.12.21 18129 0
196 LINUX 삼바(SAMBA)를 이용한 윈도우 접근 가능 공유폴더 만들기 2016.02.23 18242 0
195 개념 CFM(Content Forward Management) 2012.01.27 18250 0
194 Pi 아두이노 데이터 저장하기(Arduino EEPROM 사용하기) 2019.12.24 18273 0
193 LINUX 계정등록(adduser) 기능 및 옵션, 계정 변경(usermod) 5 2013.03.29 18338 0
192 C# c# 다국어 개발 2012.05.22 18382 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