PHP Variables
Rules for PHP variables:
- A variable starts with the
$sign, followed by the name of the variable - A variable name must start with a letter or the underscore character
- A variable name cannot start with a number
- A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )
- Variable names are case-sensitive (
$ageand$AGEare two different variables)
PHP supports the following data types:
- String
- Integer
- Float (floating point numbers – also called double)
- Boolean
- Array
- Object
- NULL
- Resource
To get the data type of a variable, use the var_dump() function or use the echco gettype() function.
var_dump($name);
echo gettype($name);
Variable can assign in between double cotation.
Change Data Type- $num=(string)$age;
echo can have multiple parameters.
echo" First Name ", $fname; //echo can have multiple parameters.
echo ” First Name.$fname”; // dot sign is as concatenation
echo ” First Name $fname”;
$name=”seelan”;
$$name=”yohga”;
echo $name; //seelan
echo $seelan; //yohga
echo $$name; //yohga



Leave a Reply