http_redirect
(PECL pecl_http >= 0.1.0)
http_redirect — Issue HTTP redirect
Description
$url
[, array $params
[, bool $session
= false
[, int $status
= 0
]]]] )Redirect to the given url.
The supplied url
will be expanded with http_build_url(), the params
array will
be treated with http_build_str() and the session identification will be appended
if session
is true. The HTTP response code will be set according to status
.
You can use one of the redirect constants for convenience.
Please see » RFC 2616
for which redirect response code to use in which situation. By default PHP will decide which response status fits best.
To be RFC compliant, "Redirecting to <a>URL</a>." will be displayed, if the client doesn't redirect immediately, and the request method was another one than HEAD.
A log entry will be written to the redirect log, if the INI setting http.log.redirect is set and the redirect attempt was successful.
Parameters
-
url
-
the URL to redirect to
-
params
-
associative array of query parameters
-
session
-
whether to append session information
-
status
-
custom response status code
Return Values
Returns FALSE
or exits on success with the specified redirection status code.
See the INI setting
http.force_exit for what "exits" means.
Examples
Example #1 A http_redirect() example
<?php
http_redirect("relpath", array("name" => "value"), true, HTTP_REDIRECT_PERM);
?>
The above example will output:
HTTP/1.1 301 Moved Permanently X-Powered-By: PHP/5.2.2 Content-Type: text/html Location: http://www.example.com/curdir/relpath?name=value&PHPSESSID=abc Redirecting to <a href="http://www.example.com/curdir/relpath?name=value&PHPSESSID=abc">http://www.example.com/curdir/relpath?name=value&PHPSESSID=abc</a>.
- http_cache_etag
- http_cache_last_modified
- http_chunked_decode
- http_deflate
- http_inflate
- http_build_cookie
- http_date
- http_get_request_body_stream
- http_get_request_body
- http_get_request_headers
- http_match_etag
- http_match_modified
- http_match_request_header
- http_support
- http_negotiate_charset
- http_negotiate_content_type
- http_negotiate_language
- ob_deflatehandler
- ob_etaghandler
- ob_inflatehandler
- http_parse_cookie
- http_parse_headers
- http_parse_message
- http_parse_params
- http_persistent_handles_clean
- http_persistent_handles_count
- http_persistent_handles_ident
- http_get
- http_head
- http_post_data
- http_post_fields
- http_put_data
- http_put_file
- http_put_stream
- http_request_body_encode
- http_request_method_exists
- http_request_method_name
- http_request_method_register
- http_request_method_unregister
- http_request
- http_redirect
- http_send_content_disposition
- http_send_content_type
- http_send_data
- http_send_file
- http_send_last_modified
- http_send_status
- http_send_stream
- http_throttle
- http_build_str
- http_build_url
Коментарии
404 Not Found