The only solution that worked for me was to set the output_buffering
directive in php.ini to "Off". I didn't want to do this for the entire server, just this one specific resource. Normally you could use ini_set
from the PHP script, but for whatever reason php doesn't allow output_buffering
to be set in this way (see the php manual).
Well it turns out that if you're using Apache, you can set some php ini directives (including output_buffering
) from your server config, including a .htaccess file. So I used the following in a .htaccess file to disable the output_buffering just for that one file:
<Files "q.php">
php_value output_buffering Off
</Files>
And then in my static server configuration, I just needed AllowOverride Options=php_value
(or a larger hammer, like AllowOverride All
) in order for that to be allowed in a .htaccess file.