
header()ҪǽHTTPЭͷ(header)
void header ( string $string [, bool $replace = true [, int $http_response_code ]] ) ѡreplaceָ滻ǰһƱͷһͬ͵ıͷĬΪ滻
ڶѡhttp_response_codeǿƽHTTPӦΪֵָ headerLocation͵ıͷһheaderãʵҳתע⣺1.location͡:ż䲻пոת
1 2 3 4 5 6 7 | <html>php/* This will give an error. Note the output * above, which is before the header() call */header('Location: http://www.example.com/');exit;?> |
ע⣺
MetaǩHTMLиṩĵԪϢıǩPHPʹøñǩҲʵҳת http-equivΪrefresh,ҳʱcontent涨ֵһʱתӦҳ档
1 2 3 | < meta http-equiv="refresh"content="1;url=http://www.baidu.com"> |
ͨʹwindows.location.href=url; ҳԶתµĵַ
1 2 3 4 5 6 7 | < ?php $url = "http://www.baidu.com"; echo "< script language='javascript'type='text/javascript'>"; echo "window.location.href='$url'"; echo "< /script>"; ?> |