Assigning HTTP Request Variables to PHP Variables

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tangoking
Forum Newbie
Posts: 9
Joined: Tue Sep 22, 2009 4:31 pm

Assigning HTTP Request Variables to PHP Variables

Post by tangoking »

As the title implies, is it possible to grab HTTP request variables and assign them to PHP variables? I envision something like this:

1. HTTP request sent to http://www.mypage.com/index.php
2. HTTP request includes value pairs, such as "Accept," "Accept-Charset," "Referer" (see full list at http://en.wikipedia.org/wiki/List_of_HTTP_headers)
3. index.php will include code to grab each of these pairs; pseudocoded something like this:

Code: Select all

$accept = $_HTTP_REQUEST['Accept'];
$accept_charset = $_HTTP_REQUEST['Accept-Charset'];
$referrer = $_HTTP_REQUEST['Accept-Referer'];
etc..

While we're at it, is it possible to do the same thing with HTTP Responses?

tyvm!
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: Assigning HTTP Request Variables to PHP Variables

Post by jackpf »

apache_request_headers()
and
get_headers()


;)
Post Reply