Glossary

Content-Type and MIME Types

Content-Type is an HTTP header that tells the recipient the format of the message body. A MIME type (Multipurpose Internet Mail Extensions) is a standard for identifying content type in the format type/subtype.

Common MIME types

Usage

// Server response
header('Content-Type: application/json; charset=utf-8');
echo json_encode($data);

// File download
header('Content-Type: application/pdf');
header('Content-Disposition: attachment; filename="invoice.pdf"');
readfile($path);

Accept header

The client specifies which types it accepts: Accept: application/json, text/html. The server may return different formats accordingly (Content Negotiation).