✔ 最佳答案
header
(PHP 3, PHP 4 , PHP 5)
header -- Send a raw HTTP header
Description
void header ( string string [, bool replace [, int http_response_code]])
.....
header() is used to send raw HTTP headers. See the HTTP/1.1 specification for more information on HTTP headers.
......
The second special case is the "Location:" header. Not only does it send this header back to the browser, but it also returns a REDIRECT (302) status code to the browser unless some 3xx status code has already been set.
<?php
header(”Location:
http://www.example.com/”); /* Redirect browser *//
/* Make sure that code below does not get executed when we redirect. */
exit;
?>
Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include(), or require(), functions, or another file access function, and have spaces or empty lines that are output before header() is called. The same problem exists when using a single PHP/HTML file.