PHP  
downloads | documentation | faq | getting help | mailing lists | | php.net sites | links | my php.net 
search for in the  
<gmp_xorheader>
view the version of this page
Last updated: Sat, 19 Apr 2003

XXXVII. HTTP functions

Einf�hrung

Diese Funktionen erm�glichen die Manipulation der an den Browser gesendeten Informationen auf HTTP-Protokoll-Ebene.

Anforderungen

Diese Erweiterung ben�tigt zur Erstellung keine externen Bibliotheken.

Installation

F�r diese Funktionen ist keine Installation erforderlich, diese geh�ren zum Grundbestand von PHP.

Laufzeit Konfiguration

Diese Erweiterung definiert keine Konfigurationseinstellungen in der php.ini.

Resource Typen

Diese Erweiterung definiert keine Resource-Typen.

Vordefinierte Konstanten

Diese Erweiterung definiert keine Konstanten.

Inhaltsverzeichnis
header -- Sendet einen HTTP-Header
headers_sent -- Pr�ft, ob oder wo die Header bereits gesendet wurden
setcookie -- Sendet ein Cookie


User Contributed Notes
HTTP functions
add a note
jrochkin at cs dot oberlin dot edu
24-Mar-2000 10:54

See the file() function. It works on http requests too, even though it's grouped with filesystem functions.
dave at kineticenergy dot com
28-Mar-2000 07:49

try this to get your current url
$filelocation=$HTTP_HOST.$PHP_SELF;
echo($filelocation);

hercules at drinkspecials dot com
23-Apr-2000 04:50

To make a page that refreshes itself every 10 seconds, use a meta tag. <META HTTP-EQUIV="Refresh" CONTENT="10; URL=>
The previous tag will cause the page that you are on to refresh in 10 seconds
to .

dhpainter at msn dot com
26-Apr-2000 05:35

To create a link to the previous page you can use the
getenv("HTTP_REFERER")
command and  set it up as a hyperlink. You might also want to put a IF condition on it so it won't get displayed if the user has gone straight in to the page.

rob at OhReally dot com
29-Jun-2000 03:59

To display the current URL, I'd rather use
$REQUEST_URI
or
$SERVER_NAME.$REQUEST_URI
This will include the query-string.
Make a phpinfo() file to see all environment variables.

Rob

rob at OhReally dot com
08-Jul-2000 03:22

To redirect your visitors without interference (no warning/explanation) you should use
header("Location: );
If you would first like to tell your visitors what is going to happen ('You'll be redirected in 5 secs') you should consider meta-tags or JavaScript.

jeffp-php at outofservice dot com
05-Jan-2001 03:37

$HTTP_RAW_POST_DATA --

You'll usually access variables from forms sent via POST method by just accessing the associated PHP global variable.

However, if your POST data is not URI encoded (i.e., custom application that's not form-based) PHP won't parse the data into nice variables for you.  You will need to use $HTTP_RAW_POST_DATA to access the raw data directly. (This should return a copy of the data given to the PHP process on STDIN; note that you wan't be able to open STDIN and read it yourself because PHP already did so itself.)

krisj at blueridge dot net
23-Jan-2001 11:41

When using the $SERVER_NAME or other predefined variables within a function BE SURE to use $GLOBALS["SERVER_NAME"] in its place =)
tl dot NO SPAM at ccf dot NO SPAM dot fr
16-May-2001 08:18

Please note, in previous message, Decode_Chunked_Message() function will fail in some case (whitespace between chunk size and crlf)
To avoid this :
modify line $chunk_size=substr($message,$chunk_pos,$crlf_pos);
by
$chunk_size=chop(substr($message,$chunk_pos,$crlf_pos));
AND
$chunk_size=substr($message,$chunk_pos,$crlf_pos-$chunk_pos);
BY
$chunk_size=chop(substr($message,$chunk_pos,$crlf_pos-$chunk_pos));

paul at siroccoh dot com
30-Jun-2002 06:04

Redirecting:
If you want the URL you are redirecting to with header("Location: $url") to appear in the location bar in your browser, you have to add a <CRLF> at the end of the string; ie header("Location: blah.com\r\n") It'll still redirect without the \r\n but for some reason the URL remains unchanged in the location bar.

tom at tom420 dot com
12-Aug-2002 06:42

The last post must be related with an older version of some browser. I've tried it with both IE 6.0 (which comes with XP) and Mozilla 1.1, both with \r\n and without it, and in both cases the new URL shows up in the address bar.

I do remember such a glitch with IE in the past however.

nf at wh3rd dot net
06-Sep-2002 06:57

If you're wanting to perform an HTTP POST, I've written a small but useful function to do so:


breaker at coder dot hu
15-Mar-2003 03:15

[Editor's Note:] This method uses JavaScript which requires the visitor's browser to have javascript enabled [/Note]

Another way, to redirect to an url without any notification or message:
Print("window.location='$urlvar';");

nstansbury at redbacksystems dot com
05-May-2003 05:35

I wanted to do an http redirect taking into account their current uri:

ie. authentication failed - redirect to login.php

$NewPage = 'login';
$NewURL = preg_replace( "[\w+(?=\.php)]", $NewPage, $_SERVER[ "SCRIPT_URI" ] );
header( "location: $NewURL\r\n" );

Hope this might be useful for someone.

add a note

<gmp_xorheader>
 Last updated: Sat, 19 Apr 2003
show source | credits | mirror sites 
Copyright © 2001-2003 The PHP Group
All rights reserved.
This mirror generously provided by: /
Last updated: Wed May 14 01:12:44 2003 CEST