PHP
2014.06.02 14:27

Header for XML content in PHP file

조회 수 11266 댓글 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
번호 분류 제목 날짜 조회 수 추천 수
17 PHP 파일 데이터 저장하고 불러오기(파일 입출력) 2015.09.30 8390 0
16 PHP 윈도우용 센드메일 구축 2016.03.30 8288 0
15 PHP [PHP] .php 확장자 없이 URL 접속하기 2020.10.26 4473 0
14 PHP [MySQL] 뷰 생성하기(VIEW 생성하기) 2022.10.12 1007 0
13 PHP sQL:: JOIN, UNION 사용법 2022.09.05 1082 0
12 PHP SQL 일정 시간단위로 데이터 검색하기 2020.02.12 4919 0
11 PHP SQL :: EXIST , NOT EXIST 2022.09.05 1318 0
10 PHP Simple GD example 2014.07.10 7742 0
9 PHP php 배열 사용하기 2015.10.28 12272 0
8 PHP PHP 문자열 다루기 2015.06.30 24701 0
7 PHP php 기본 문법 정리 secret 2014.01.16 0 0
6 PHP PHP GD 설명 2014.07.09 10038 0
5 PHP MySQL 기본 문법 2014.03.01 12445 0
4 PHP move_uploaded_file() 2014.04.29 10339 0
» PHP Header for XML content in PHP file 2014.06.02 11266 0
목록
Board Pagination ‹ Prev 1 2 Next ›
/ 2

나눔글꼴 설치 안내


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

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

설치 취소

Designed by sketchbooks.co.kr / sketchbook5 board skin

Sketchbook5, 스케치북5

Sketchbook5, 스케치북5

Sketchbook5, 스케치북5

Sketchbook5, 스케치북5