0
header("Content-type: text/css");
echo 'sometext';
exit;

in my browser I still see the type text/html, why is that?

8
  • Which browser are you using? Commented Feb 15, 2014 at 21:35
  • Could it be because it is not valid CSS and therefore the browser sets it to the default text/html (I don't know, just worth a try)? Commented Feb 15, 2014 at 21:36
  • Are you sure there's no other output with a silent "headers already sent" error message? Commented Feb 15, 2014 at 21:37
  • @jori: that's not the server or browser's problem. if you say the content is text/css, that'll be the header. Whether the actual response body contains CSS or something entirely different is not up to the http layer to determine. Commented Feb 15, 2014 at 21:38
  • Yes, I know that should be the behavior, but it is at least worth a try. Oh hell, i'll try it myself, 1 sec... Commented Feb 15, 2014 at 21:39

1 Answer 1

2

The comments already say it, but try to print/echo some real css-content. if your file is still detected as text/html, turn error-messaging on and see if there is a "headers already send"-warning, which indicates that your php-script echoed some whitespace before the header("...")-codeline.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.