Example 1 — Queue Content-Type and a Custom Header
Set two response headers, then list them with headers_list(). On a web SAPI you see the queued lines; CLI may show an empty list.
<?php
header("Content-Type: text/plain; charset=UTF-8");
header("X-Tutorial: demo");
foreach (headers_list() as $line) {
echo $line, PHP_EOL;
} How It Works
- header() queues Content-Type before any body text.
- A custom X-Tutorial header is added the same way.
- headers_list() returns the headers ready to send on a web SAPI.
- The output above is the illustrative web-SAPI listing; CLI often prints nothing.

