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:

$GLOBALS Contains a reference to every variable that is available within the global scope of the script.
$_SERVER Variables set by the web server and/or otherwise directly related to the execution environment of the script.
$_GET Variables provided to the script via a URL query string.
$_POST Variables provided to the script via the 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 the GET, POST, and COOKIE inputs. These variables cannot be trusted.
$_SESSION Variables which are currently registered to a scripts’s session

Rate This Entry:
Vote This Post DownVote This Post Up (No Ratings Yet)
Loading ... Loading ...

Leave a Reply

Phone Support
Need Help? Call us today.
Hours: 8am - 5pm PST 1-877-588-5461
Join Our Community!
Discuss issues online with other web developers.
Visit Our Community!
24/7 Email Support
Contact our technical support team via email.
Submit Support Ticket
Server Status
Think there might be a server outage?
Server Notifications
Home | Services | Support | Network | User Forums | Contact Us
Questions? Call Us Toll Free At: 1-877-588-5461
Home
Contact Us