Advertising


Navigation
External Links
Banner

Environmental Variables

Remember that section where we covered variables? Well this is like the same thing... only easier. An environmental variable is one that is not set by you, the coder. It's set by, you guessed it, the environment, I'm not talking trees and stuff but the digital equivalent. Environmental variables cover stuff such as, the current time on the server, a visitor's IP address, a visitor's browser, the current page, what page the visitor came from... The list goes on so yeah. So here goes:

$GLOBALS
Contains a reference to every variable which is currently available within the global scope of the script. The keys of this array are the names of the global variables.
$_SERVER
Variables set by the web server or otherwise directly related to the execution environment of the current script.
$_GET
Variables provided to the script via HTTP GET.
$_POST
Variables provided to the script via HTTP POST.
$_COOKIE
Variables provided to the script via HTTP cookies.
$_FILES
Variables provided to the script via HTTP post file uploads.
$_ENV
Variables provided to the script via the environment.
$_REQUEST
Variables provided to the script via any user input mechanism, and which therefore cannot be trusted. The presence and order of variable inclusion in this array is defined according to the variables_order configuration directive.
$_SESSION
Variables which are currently registered to a script's session.



Here is one you'll use fairly often:
$_SERVER[REMOTE_ADDR]   This returns the visitor's current IP address.

Try it.

There's more here.


    <?PHP
       echo $_SERVER[REMOTE_ADDR] ;
    ?>

This should display your IP address.

For now this should just be a reference guide. You should know that it exists. We'll return to this later.


Page 3 of 6

Previous 1 2 3 4 5 6 Next