Mayron Mia
Mayron Mia

Reputation: 33

Send multiple HTTP headers with single header() call in PHP

I send the headers for Cache and Content Type for different languages to show the correct characters, but it does not work.

header('Cache-control: private; Content-Type:text/html; charset=UTF-8');

What am I doing wrong?

Upvotes: 2

Views: 1799

Answers (1)

Michał Perłakowski
Michał Perłakowski

Reputation: 92511

You can't send multiple headers in one header() call. Split it like that:

header('Cache-control: private;');
header('Content-Type:text/html; charset=UTF-8');

Generally, when you send headers, you separate them by new lines, but if you try to do this with PHP's header() function, you get warning:

Header may not contain more than a single header, new line detected

Upvotes: 3

Related Questions