Tuesday, October 23, 2012

PHP Tutorial: What are PHP Variables?


Let's make it simple, variables are nothing but "containers", containers that simply hold values or information in PHP scripting.

Okay lets break it down even further, let's go back to school level, remember ALGEBRA! Yes..... where;

x=2, y=8, find whatever you like?

Similar to that, where x holds a particular value here in above example it is "2" and letter "x" will act as a variable which holds assigned value that is "2" within it.

Rules for PHP Variables Names:

1. Variables in PHP starts with a $ sign followed by the names of the variables.

2. Variables name you are going to use must begin with a LETTER or with a underscore character.

3. Variable name can only contains alpha numeric characters and underscore such as (A-z, 0-9 and _). No special character can be used while naming your variable.

4. No space can be included or left while naming.

5. It important to know that variable names are case sensitive (a and A will act as two different variables).


1 comment: