i notice a thing about header function in php.....sometimes we used it as

1.header("Content-type: $contenttype"); //i saw this in a dynamic page
2.header("Content-type: $image/png"); //saw this in a captcha create page
3.header("location:bird.php"); // this one i understand
4.header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: no-cache");
header("Pragma: no-cache"); //saw these in w3schools, says some cache-control

but i only get 3rd one(bird.php), didnt know what it actually does...so any help..??

Recommended Answers

All 4 Replies

header("location:bird.php")

It refer to redirection to bird.php page

header("Content-type: $contenttype"); //to ensure the receiving pc can display the developed page in the correct way, the content type may be different for each object pulled from the database
header("Content-type: image/png"); //to ensure the receiving pc can display the developed page in the correct way, the normal content type for served php pages is text/html, likely the original did not have a dollar sign
header("location:bird.php"); // this one i understand, yep redirect
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: no-cache");
header("Pragma: no-cache"); //each of these three to ensure the browser reloads the item from the server, make sure of the most recent version, expired 20 years ago, nocache for each of the two major object models
Member Avatar for cuonic

You are doing it wrong, you are setting headers for the page, then sending the user elsewhere...

You need to set the headers, then do a readfile if you are opening a file

You are doing it wrong, you are setting headers for the page, then sending the user elsewhere...

You need to set the headers, then do a readfile if you are opening a file

bloke, the op is asking what the headers do, giving specific examples, we could have "let me google that for you" or sent him to read the manual http://php.net/manual/en/function.header.php but he showed some effort, has been examininig the source

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.