PHP Headers and Mime Types

July 29th, 2012 by laeeq | 2 comments

In previous post, I have explained about email send using php email header content type and Mime types.

Actually PHP’s header() is used to send a raw HTTP header. header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. By using Header, you can tell the browser that you’re outputting a different content type in spite of current file extension ends in PHP. Here in this post I have collected a list of popular Header’s content types that’s surely works for you.

List of popular Header’s content types

Text (Print Plain text)

  1. header(‘Content-type: text/plain’);

XML (Print as XML)

  1. header(‘Content-type: text/xml’);

CSS (Sets content type as CSS)

  1. header(‘Content-type: text/css’);

Atom (Sets as Atom)

  1. header(‘Content-type: application/atom+xml’);

Javascript (Content type as JavaScript)

  1. header(‘Content-type: text/javascript’);

JPEG Image (Content as JPEG Image)

  1. header(‘Content-type: image/jpeg’);

JSON  (Set type as JSON)

  1. header(‘Content-type: application/json’);

PDF  (Sets content type as PDF)

  1. header(‘Content-type: application/pdf’);

RSS (Content type as RSS)

  1. header(‘Content-Type: application/rss+xml; charset=ISO-8859-1′);

 

You can subscribe to PHPZAG.COM posts by Email

 

Related Topics:

 

 

  1. July 29th, 2012 at 16:07 | #1

    This website really has all of the info I needed about this subject and didn’t know who to ask.

  2. November 7th, 2012 at 10:25 | #2

    I was extremely pleased to discover this great site. I want to to thank you for ones time for this particularly fantastic read!! I definitely really liked every bit of it and i also have you book marked to check out new things on your website.

  1. No trackbacks yet.