Number Of Page View:100,000+/Months
LOGIN |New User


How to declare data types in PHP?
Data type that we used in PHP are given below:
1.Numeric data type
2.Array data type
3.String data type
1.Numeric data type: We introduce numeric data type when we use numbers in PHP.Two different types of numeric data types are integer and double.
 integer data type use to introduce the whole number.Where as double data type use to introduce float values.
$intnum = 50;
$doublepercentage = 67.9;
2.Array data type: In this we store many values in a single variable.In this we show all values of variable with their variable and index.
$arrayMarks[0] = 70;
$arrayMarks[1] = 75;
$arrayMarks[2] = 65;
$intTotalMark = $arrayMarks[0] + $arrayMarks[1] + $arrayMarks[2];
echo $intTotalMark;
Output: 210 
3.String data type:In this values of variables may be of combination of characters and numbers or words.
$stringName = "Abhi";
$stringId = "Abhi007";

String Concatenation:In thois we can add two strings using "."operator.When we add two strings second string add at the end of first string.
$stringFirst_Name = "vivek";
$stringSpace = " ";
$stringLast_Name = "agarwal";

$stringName = $stringFirst_Name.$stringSpace.$stringLast_Name;
echo $stringName;

Output: vivek agarwal

Posted By: Name:Rajesh Kr URL: How to declare data types in PHP?