I have written a function called IO::stdout:
class IO {
public static function stdout($var) {
$stdout = fopen('php://stdout', 'w');
fwrite($stdout, $var, strlen($var));
fclose($stdout);
}
}
IO::stdout("Hello World!");
Well, it works! But when I request the page, it displays me:
Hello World!
X-Powered-By: PHP/5.6.13
Content-type: text/html; charset=UTF-8
Setting expose_php = Off in php.ini removed the X-Powered-By header, but the Content-Type header is still printed. It is probably added by Lighttpd. How do I disable the Content-Type header?
This is the default PHP header: http://php.net/manual/fr/ini.core.php#ini.default-mimetype
You can't remove it using header_remove, as a missing Content-Type header will trigger the default mime-type.
Instead, try to set it to an empty string:
header('Content-Type:', true);
true will erase any previous similar header.
And just for the record, headers' names are case insensitive, and PHP is known to send the Content-type with a small t.
Also you can send the right Content-Type (which should be text/plain I think).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With