24.3. Setting Document Type

By default, PHP sends an HTTP header specifying the document as being HTML. The Content-Type header specifies the MIME type text/html, and the browser interprets the code as HTML. Sometimes you will wish to create other types of documents with PHP. Chapter 25 discusses creating images, which may require an image/png content type. MIME types are administered by IANA, the Internet Assigned Numbers Authority. You can find a list of official media types at <http://www.isi.edu/in-notes/iana/assignments/media-types/>.

At times, you may wish to take advantage of how browsers react to different types of content. For example, text/plain displays in a fixed-width font with no interpretation of HTML. If you use */* for the content ...

Get Core PHP Programming, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.