Changes

An Introduction to PHP Variables

1,012 bytes added, 14:11, 25 May 2007
no edit summary
When working with data values in PHP we need some convenient way to store these values so that we can easily access them and make reference to them whenever necessary. This is where PHP variables come in.
 
It is often useful to think of variables as computer memory locations where data is to be stored. When declaring a variable in PHP it is assigned a name that can used to reference it in other locations in the PHP script. The value of the variable can be accessed, the value can be changed, and the type of variable can be altered all by reference the name assigned at variable creation time.
 
== Creating a Variable in PHP ==
 
before learning how to declare a variable in PHP it is first important to understand some rules about variable names (also known as variable naming conventions). All PHP variable names mustr begin with a ''$''. It is this prefix that informs the PHP pre-processor that a variable is being declared. The second character of the name must be either a letter or an underscore (_). The remaining characters must comprise only letters, numbers or underscores. All other character are deemed to be invalid for use in variable name.
 
Let's look at some valid and invalid PHP variable names: