PHP School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a PHP Expert!

Join 300,504 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,904 people online right now. Registration is fast and FREE... Join Now!




header(...)

 

header(...), The purpose...?

Vomster

30 Jun, 2009 - 04:19 AM
Post #1

D.I.C Head
**

Joined: 15 May, 2008
Posts: 142



Thanked: 6 times
My Contributions
What is the purpose of using this function?

I ask because can't you just use require or include?

User is offlineProfile CardPM
+Quote Post


shadhin

RE: Header(...)

30 Jun, 2009 - 04:26 AM
Post #2

D.I.C Regular
Group Icon

Joined: 16 Sep, 2008
Posts: 422



Thanked: 19 times
Dream Kudos: 3650
My Contributions
header() function sends a raw HTTP header to a client.
Take a look at the manual for details.
User is online!Profile CardPM
+Quote Post

Vomster

RE: Header(...)

30 Jun, 2009 - 05:19 AM
Post #3

D.I.C Head
**

Joined: 15 May, 2008
Posts: 142



Thanked: 6 times
My Contributions
I read that before I posted but I didn't understand the concept I guess. I'm just confused as to why someone would use that over require and include.

Was looking for someone to give me a better example and reason than what they had on that page.
User is offlineProfile CardPM
+Quote Post

thehat

RE: Header(...)

30 Jun, 2009 - 05:28 AM
Post #4

awake ? web();
Group Icon

Joined: 28 Feb, 2008
Posts: 894



Thanked: 90 times
Dream Kudos: 175
My Contributions
Require and include are for importing additional files into your execution.

Header lets you add http headers. These headers contain a variety of information about your page, and include any data sent by POST. A very common use of header is to perform a server-side redirect: header('Location: www.google.com');. The benefit of this over a javascript or meta tag redirect is that it can be performed before any information is sent to the client's machine, making it much faster.

Edit: it's also worth noting that header() cannot be used after any page content has been processed.

This post has been edited by thehat: 30 Jun, 2009 - 05:30 AM
User is offlineProfile CardPM
+Quote Post

Vomster

RE: Header(...)

30 Jun, 2009 - 05:58 AM
Post #5

D.I.C Head
**

Joined: 15 May, 2008
Posts: 142



Thanked: 6 times
My Contributions
So basically it's used for redirecting to another page/site?
User is offlineProfile CardPM
+Quote Post

thehat

RE: Header(...)

30 Jun, 2009 - 06:29 AM
Post #6

awake ? web();
Group Icon

Joined: 28 Feb, 2008
Posts: 894



Thanked: 90 times
Dream Kudos: 175
My Contributions
No, that's only one of it's many uses.

When people talk about http headers, they are referring to a lot of information that is sent ahead of a web page to inform the browser. Using the header() function, you can modify these headers. To see them, I recommend using Firefox and the 'Live HTTP Headers' extension. Once you see headers in action you should have a better idea of what header() can do.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/8/09 05:05AM

Live PHP Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month