Web-Related Variables
PHP automatically creates global variables for all the data it receives in an HTTP request. This can include GET data, POST data, cookie data, and environment variables. Say you have an HTML form that looks as follows:
<FORM ACTION="test.php3" METHOD="POST"> <INPUT TYPE=text NAME=var> </FORM>
When the form is submitted to the test.php3
file, the $var
variable within that file is set to
whatever the user entered in the text field.
A variable can also be set in a URL like this:
http://your.server/test.php3?var=Hello+World
When the request for this URL is processed, the
$var
variable is set for the
test.php3
page.
Any environment variables present in your web serverâs configuration are also made available, along with any CGI-style variables your web server might set. The actual set of variables varies between different web servers. The best way to get a list of these variables is to use PHPâs special information tag. Put the following code in a page and load the page in your browser:
<? phpinfo( ) ?>
You should see a page with quite a bit of information about PHP and
the machine it is running on. There is a table that describes each of
the extensions currently enabled in PHP. Another table shows the
current values of all the various configuration directives from your
php3.ini
file. Following those two tables are more tables showing the regular environment variables, the special PHP internal variables, and the special environment variables that your web server ...
Get PHP Pocket Reference now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.