using header

A

Anonymous

Guest
hi
i want explain to what profit from header(); and how i do good using for it
notice i read manual php already but i can not understand yet clearly
 
Data from and to your browser always start with a header which contains some basic information about the type of data, amount of data, etc.

In PHP you will most often use custom headers to:
• disable caching
• set content type
• redirect

If you set or clear a cookie, that is also sent as part of the header, allthough you don't use the header function for it. If you use sessions, session info is also sent as part of the header.

Note that a header has to be sent before any other data, and therefor you cannot send any more headers once you've started outputting other data (even a blank). Eg this would fail:

Code:
<?php
require_once("lib.php");
?>
<?php
header("Location: /index.php");
?>
Because there is a newline after the first php close tag, that newline is sent as regular output and headers cannot be sent after that.

Coditor[/list][/list]
 
Back
Top