Some variables have a special purpose in PHP, that is they
are reserved to hold specific values and are created by PHP
itself, also built in function names cannot be used as
The PHP manual has a full list of these variables, but some
of the more important ones are the array collections
$_POST , $_GET ,
$_REQUEST, $_SERVER and
$_ENV, We'll cover arrays in more detail at a
later date, but for now if you look at the phpinfo script
that we created in the second article in the series, you'll
see near the bottom that there is a list of the elements in
the $_SERVER and $_ENV variables.
To get the value of these variables simply use the variable
name followed by the item name quoted in square brackets,
The $_POST, $_GET and
$_REQUEST variables are populated by values
passed to your script. We'll look at $_POST in the article
on arrays, but for now if you try running your script using
you'll find that the variables $_GET["myvar"]
and $_GET["age"] will hold the values "hello"
and 21 respectively.
In this episode of the ABC's of PHP we looked at the basics
of using variable data in your script, and how they can be
used, over the next three parts we'll look at the different
types of data in more detail starting in part 5 with strings
and text. Then in part 6 we'll cover maths and numbers.
In the mean time the variables page in the PHP manual is
worth a read, particularly the page on the predefined
variables, as there are a couple of warnings in there about
using globals, and the register-globals depreciated