Info
Content

Content-Type headers

Depending on what types of media you want to display using PHP, you need to set different values in the response header. This is done using an internet media type, also known as a MIME type or content type. It is a standard designed to indicate the type of information a file or piece of data contains.

Every single media type must adhere to the following format:

[type]/[tree].[subtype] +[suffix] ;[parameters]

The tree, suffiix and parameters sections are optional.

There are nine types, each with their own list of subtypes.

  • application
  • audio
  • example
  • image
  • message
  • model
  • multipart
  • text
  • video

The below sections will detail some of the more common subtypes for each type.

Application

Type: application

  • application/json - data encoded in JSON format.
  • application/javascript - Javascript files
  • application/pdf - a PDF document
  • application/rss+xml - RSS data in XML format
  • application/xml - data encoded in XML format
  • application/(g)zip - compressed (G)ZIP data
  • application/x-tar - Tarball
Audio

Type: audio

  • audio/basic -  μ-law format, at 8 kHz, 1 channel
  • audio/mp4 -  MP4 format
  • audio/mpeg - MP3 or any other MPEG format
  • audio/vnd.wave - WAV format
  • audio/webm - WebM open media format
Images

Type: image

  • image/<pretty much any image type here>
  • image/svg+xml - SVG image
  • image/x-xcf - GIMP's file format
Text

Type: text

  • text/cmd - commands
  • text/css
  • text/csv
  • text/html
  • text/markdown
  • text/javascript - JavaScript (made obsolete in favor of application/javascript, but better supported)
  • text/plain - Plain old boring data
  • text/rtf
  • text/xml
Video

Type: video

  • video/avi -  Covers most Windows formats including .avi and .divx
  • video/mpeg - MPEG-1 video
  • video/mp4 - MP4 video.
  • video/ogg - Ogg Theora or other video (with audio).
  • video/quicktime - QuickTime video
  • video/webm - WebM open media format
  • video/x-ms-wmv - Windows Media Video (WMV)
  • video/x-flv - Flash video

 

No Comments
Back to top