PHP-Variables and Data Types | How to Use Variables in PHP | PHP Data Types
Variables and Data Types in PHP: -
To Store Different Data in a Variable.
PHP supports the Following Data Types.
- String
- (String is a sequence of Characters)
- String can be any text inside the code
- exp : $name="Visually Teach";
- Integer
- none decimal Numbers
- Integer formats are :
- Decimals
- Hexadecimals
- octal
- Exp:
- $my_Age=30;
- Float (Floating point number - also called double)
- Floating is number with decimal points / Double Numbers.
- exp: -
- $my_GPA=9.7;
- Boolean
A Boolean represents two things : TRUE or FALSE.
Booleans used in conditional testing.
Exp:
$x = true; $y = false;
- Array: -
- To stores multiple values in one single variable
- Exp:
- $courses=array("Graphic Application","Web Application","Digital Marketing");
- When you Print: -
- echo $courses[0] . ", " . $courses[1] . " and " . $courses[2] . "."
Array Types : -
There are three types of arrays:
Indexed arrays - Arrays with numeric index
Associative arrays - Arrays with named keys
Multidimensional arrays - Arrays containing one or more arrays
There are three types of arrays:
Indexed arrays - Arrays with numeric index
Associative arrays - Arrays with named keys
Multidimensional arrays - Arrays containing one or more arrays
How to write Simple Program for Variable and Data Types: -
<?php
$jit="jeevanIT Computer Education";
$course="Web Development";
$fee=15000;
$adm_fee=100;
echo $jit;
echo "<br>";
echo $fee." + ".$adm_fee;
echo "=";
echo $fee+$adm_fee;
?>
Comments
Post a Comment