Weberz Knowledge Base: PHP: variables
PHP: variables

Variables in PHP are represented by a dollar sign followed by the variable name. The variable name is case-sensitive.

Variable names follow the same rules as other labels in PHP. The name must start with a letter or underscore, followed by any number of letters, numbers, or underscores. Valid characters for a variable name are '[a-zA-Z_x7f-xff][a-zA-Z0-9_x7f-xff]*' (sans quotes).

There is a new set of powerful predefined arrays that contain variables from the webserver, user-input and the environment. These arrays are known as superglobals. Here is a listing of superglobals:

$GLOBALSContains a reference to every variable that is available within the global scope of the script.
$_SERVERVariables set by the web server and/or otherwise directly related to the execution environment of the script.
$_GETVariables provided to the script via a URL query string.
$_POSTVariables provided to the script via the HTTP POST.
$_COOKIEVariables provided to the script via HTTP COOKIES.
$_FILESVariables provided to the script via HTTP POST file uploads.
$_ENVVariables provided to the script via the environment
$_REQUESTVariables provided to the script via the GET, POST, and COOKIE inputs. These variables cannot be trusted.
$_SESSIONVariables which are currently registered to a scripts's session

Article Information
Number: 058
Created: 03-07-2005
Modified: 08-18-2005
Rating: (None)
Email This Article
Print Article
Add Comment
How helpful was this article to you?  
User Comments
No comments have been posted.
Add Comment
» Weberz » Support Center » Knowledge Base