You already met and used $_POST. It held the data from a form which had been submitted by the user. It is known as a superglobal for reasons which do not really matter. There are other superglobals and some are potentially useful. All of them are arrays so they contain more than one item of data which you need to access by identifying each one with it's key just like you did by using $_POST["text1"]. One example might help. Open your PHP template and save it as phpglobals.php. Paste this code into it:
$ip=$_SERVER["REMOTE_ADDR"]; echo "<p>$ip</p>";
Note that superglobals use capitals which is a good reason not to use capitals in your code. It is intended to make it clear when you use superglobals. Their name also starts with an underscore character.
Save, upload and try. If you are using XAMPP the result will not be impressive. If you are using a proper server the result will look something like this:
This is the IP address of the user's computer as it appears on the Internet. In XAMPP you just get a couple of colons and a 1.
Copy and paste those two lines of code as extra lines in phpglobals.php. Amending them to try out some of these more interesting examples:
- the name of the current page and it's location on the server $_SERVER["PHP_SELF"]
- the IP address of the server $_SERVER["SERVER_ADDR"]
- the name of the server $_SERVER["SERVER_NAME"]
- the IP address of the person viewing the page $_SERVER["REMOTE_ADDR"]
- the browser the user is using $_SERVER["HTTP_USER_AGENT"]
There are other superglobals which you will meet later.