PHP
2014.06.02 14:27

Header for XML content in PHP file

조회 수 11473 댓글 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
번호 분류 제목 날짜 조회 수 추천 수
506 LINUX UNIX COMMAND (5) : grep, sed, awk 등 2006.02.06 21352 66
505 일반 배치파일(bat 파일) 명령어 사용법 2007.01.23 43126 61
504 LINUX sed 사용법 1 2006.02.16 41938 21
503 LINUX |(파이프), grep 명령어에 대해서 2006.02.06 32788 17
502 LINUX Unix Find 명령 기본 사용법 2006.02.02 50065 16
501 LINUX awk 명령어 사용법 1 2006.02.16 115081 15
500 일반 ┗ bat(배치)파일 문법 2007.08.06 93993 8
499 LINUX [util] tar 사용법 2006.05.01 20608 7
498 Android 간단한 Handler, Runnable 사용법 1 2014.12.30 29113 1
497 Android 대화상자 만들기 메모 2023.11.01 818 0
496 Android Flutter 문법 정리 secret 2023.09.24 0 0
495 일반 PROMPT Example secret 2023.05.22 0 0
494 HTML5 typescript 기본문법 정리 2023.01.13 1556 0
493 HTML5 TypeScript 문법 정리 2023.01.13 1334 0
492 HTML5 [TypeORM] TypeORM CreateQueryBuilder 2023.01.13 1548 0
목록
Board Pagination ‹ Prev 1 2 3 4 5 6 7 8 9 10 ... 34 Next ›
/ 34

나눔글꼴 설치 안내


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

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

설치 취소

Designed by sketchbooks.co.kr / sketchbook5 board skin

Sketchbook5, 스케치북5

Sketchbook5, 스케치북5

Sketchbook5, 스케치북5

Sketchbook5, 스케치북5