Thank you for being a valued part of the CNET community. As of December 1, 2020, the forums are in read-only format. In early 2021, CNET Forums will no longer be available. We are grateful for the participation and advice you have provided to one another over the years.

Thanks,

CNET Support

Question

what is Header() function in PHP?

May 20, 2012 4:11PM PDT

what is Header() function in PHP and For what is this function used in PHP language?

Discussion is locked

- Collapse -
Answer
Strqnge question.
May 20, 2012 4:52PM PDT
- Collapse -
Answer
A lot of people use
May 21, 2012 12:17AM PDT

it to redirect the user to another page:

http://php.net/manual/en/function.header.php

If you work with PHP, you'll often see the "Warning: Cannot modify header information - headers already sent by" error, which means you already sent output to the screen and can therefore no longer send a header.

~Sovereign

- Collapse -
Answer
header function
Jul 25, 2012 11:19PM PDT

header() is used to send a raw HTTP header.It is important to notice that header() must be called before any actual output is sent..........
syntax:
header(string,replace,http_response_code)

string: Required. Specifies the header string to send.

replace: Optional. Indicates whether the header should replace previous or add a second header. Default is TRUE (will replace). FALSE (allows multiple headers of the same type).

http_response_code: Optional. Forces the HTTP response code to the specified value (available in PHP 4.3 and higher).