PHP Doku:: Issue HTTP redirect - function.http-redirect.html

Verlauf / Chronik / History: (50) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzSonstige DiensteHTTPHTTP Funktionenhttp_redirect

Ein Service von Reinhard Neidl - Webprogrammierung.

Verdiene Geld mit Deiner Homepage oder deinem Blog: Setzte eine Textlinkwerbung und bestimme den Preis selber.
Einfach kostenlos anmelden und einen Platz auf Deiner Homepage anbieten.
Make money with your homepage or blog: Set a text link advertising and declare the price.
Register free of charge and offer a place on your homepage.
HTTP Funktionen

<<http_request

http_send_content_disposition>>

http_redirect

(PECL pecl_http >= 0.1.0)

http_redirectIssue HTTP redirect

Beschreibung

void http_redirect ([ string $url [, array $params [, bool $session = false [, int $status ]]]] )

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-Einstellungen http.log.redirect is set and the redirect attempt was successful.

Parameter-Liste

url

the URL to redirect to

params

associative array of query parameters

session

whether to append session information

status

custom response status code

Rückgabewerte

Liefert FALSE oder beendet bei Erfolg with the specified redirection status code. See the INI-Einstellungen http.force_exit for what "exits" means.

Beispiele

Beispiel #1 A http_redirect() example

<?php
http_redirect
("relpath", array("name" => "value"), trueHTTP_REDIRECT_PERM);
?>

Das oben gezeigte Beispiel erzeugt folgende Ausgabe:

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>.

Siehe auch

  • die HttpResponse-Klasse, wenn sie PHP 5.1 oder höher benutzen


Verdiene Geld mit Deiner Homepage oder deinem Blog: Setzte eine Textlinkwerbung und bestimme den Preis selber.
Einfach kostenlos anmelden und einen Platz auf Deiner Homepage anbieten.
Make money with your homepage or blog: Set a text link advertising and declare the price.
Register free of charge and offer a place on your homepage.
Keine BenutzerBeiträge.
- Beiträge aktualisieren...



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)