How can I get the correct headers automatically given a filetype in PHP?
Posted
by incrediman
on Stack Overflow
See other posts from Stack Overflow
or by incrediman
Published on 2010-06-03T16:50:41Z
Indexed on
2010/06/03
16:54 UTC
Read the original article
Hit count: 163
A few times I've run into situations where I'd like to be able to include a file using PHP, and depending on the included filetype, output the appropriate headers. In the past I've just done this manually by switch/casing the extension type with the appropriate content-type headers.
However what I'm wondering now is if there's a function like
get_header($filename)
or maybe
get_contenttype($extension)
For example if I wanted to route all requests for media through a php file, I could use that function to output the correct headers.
© Stack Overflow or respective owner