Saturday, 15 December 2012

PHP Variables

Variables in php
In this Tutorial you'll learn about Variables and different Data Types in PHP.

Variable definition

Variables are nothing but identifiers to the memory location to store data. We can create any number of varibles. In PHP all the variables begin with a dollar sign "$" and the value can be assignes using the "=" operator.

$Name, $Name1, $First_Name, $Last_Name
$Name = "Pravin";
$Age = 19

Another important thing in PHP is that all the statements must end with a semicolon ";". In PHP we needn't have to specify the variable type, as it takes the data type of the assigned value. From the above example we understand that '$Name' is of Data type String and '$Age' is of type Numeric.;

Limitations in Variable Naming:

PHP has no limit on the length of variable name as in the case of other programming languages. The variable name must start with a letter or underscore. The variable name must be a combination of letters, numbers and underscores. Other characters such as *, +, #, @ are not allowed and causes error if used.

0 comments:

Post a Comment