 <p>PHP will send a chunked response by default if headers are sent and no <code>Content-Length</code> header was specified. If you're familiar with the HTTP spec, this is the only logical thing to do since the client on the other end needs to know when the HTTP message you're sending ends so it can stop reading.</p> <p>If you want to do this manually, you need to ...</p> <ol> <li>Send the appropriate headers yourself and call <code>flush()</code></li> <li>Manually output the chunked HTTP message</li> </ol> <p>So you might do something like the following. The idea is that you need to manually send your own headers and manually chunk your own message. If you simply don't send a <code>Content-Length</code> header, however, PHP will send a chunked message for you by default.</p> <pre><code>header("Transfer-encoding: chunked"); header("Trailer: X-My-Trailer-Header"); flush(); echo dechex(strlen($myChunk)) . "\r\n"; echo $myChunk; echo "\r\n"; flush(); echo "0\r\n"; flush(); echo "X-My-Trailer-Header: some-value\r\n"; flush(); </code></pre>