PHP: HTTP関連の関数 - Manual
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: Tue, 21 Dec 2004

XLI. HTTP関連の関数

導入

以下の関数は、リモートブラウザに送り返される出力を、HTTPプロトコル レベルで制御するためのものです。

要件

これらの関数は、標準モジュールの一部として利用可能であり、常に使用できます。

インストール手順

これらの関数はPHPコアに含まれるため、使用す る際にインストールは不要です。

実行用の設定

この拡張モジュールは設定ディレクティブを全く定義しません。

リソース型

この拡張モジュールはリソース型を全く定義しません。

定義済みの定数

この拡張モジュールは定数を全く定義しません。

目次
header -- 生のHTTPヘッダを送信する
headers_list -- Returns a list of response headers sent (or ready to send)
headers_sent -- ヘッダーが既に送信されているかどうかチェックする
setcookie -- クッキーを送信する
setrawcookie -- Send a cookie without urlencoding the cookie value


add a note add a note User Contributed Notes
HTTP関連の関数
WeeJames
07-Jul-2004 06:39
Regarding what the guy before said.  We've experienced problems where certain firewalls have encrypted the HTTP_REFERER meaning that it doesnt always contain the place you've come from.

Better to track where the user has come from either in a form post or in the url.
28-Apr-2004 02:05
in reference to toashwinisidhu's and breaker's note, a more effective way would be to use meta-tag redirect, for example.

<?php
$url
= ""; // target of the redirect
$delay = "3"; // 3 second delay

echo '<meta http-equiv="refresh" content="'.$delay.';url='.$url.'">';

?>

The meta goes in the head of the HTML.
This method does not require javascript and is supported by most browsers and is rarely, if ever, filterd out.
toashwinisidhu at yahoo dot com
21-Apr-2004 10:55
The method given below may not sometimes work.
The following method has always worked with me:
just put the following 3 lines in your PHP code

?>
<body onload=setTimeout("location.href='$url'",$sec)>
<?PHP
-------?>

$sec is the time in second after which the browser would automatically go to the url. Set it to 0 if you do not want to give any time.
You can use this function on the events of various html/form objects (eg.-onclick for button).eg.
<input type=button value="Go to Php.net" onclick=setTimeout("location.href='php.net'",0)>
Use this to one step back
<input type="button" value="Back" onclick=history.go(-1)>
breaker at coder dot hu
15-Mar-2003 04: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';");
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:

krisj at blueridge dot net
24-Jan-2001 12:41
When using the $SERVER_NAME or other predefined variables within a function BE SURE to use $GLOBALS["SERVER_NAME"] in its place =)
jeffp-php at outofservice dot com
05-Jan-2001 04: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.)
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.

<gmp_xorheader>
 Last updated: Tue, 21 Dec 2004
show source | credits | sitemap | contact | advertising | mirror sites 
Copyright © 2001-2005 The PHP Group
All rights reserved.
This unofficial mirror is operated at: /
Last updated: Mon Mar 14 08:13:06 2005 Local time zone must be set--see zic manual page