Your Ad Here

Saturday, November 7, 2009

What is the use of header() function in php?

PHP's header function allows you to change the headers on your returned content so that (examples)

• The browser receives not HTML but plain text, a .jpg image or a file to save locally
example: header ('Content-type: Application/Octet-stream');

• You can change a "404" missing reponse code into a "200" - good.
example: header("HTTP/1.1 200 OK");

• You can send out cache instructions
example: header("cache-control: no-store");

• you can sent out a save file name if you're saving the file.
example: header ('Content-Disposition: attachment; filename="hello.txt"');

No comments:

Post a Comment

Your Ad Here