php一問

2006-10-31 3:16 am
我想問下php有冇d function 等同asp 既 redirect??

回答 (1)

2006-10-31 3:55 am
✔ 最佳答案
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.


收錄日期: 2021-04-23 14:24:08
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20061030000051KK04897

檢視 Wayback Machine 備份