application/json — JSON data (REST API)application/x-www-form-urlencoded — HTML form datamultipart/form-data — form with file uploadstext/html; charset=utf-8 — HTML pagetext/plain — plain textimage/png, image/webp, image/svg+xmlapplication/pdfapplication/octet-stream — binary data (generic download)// 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);
The client specifies which types it accepts: Accept: application/json, text/html. The server may return different formats accordingly (Content Negotiation).