PHP data type is used for storing a data in a different form and PHP support all types of data type as comparison other programming language such as- C, JAVA, .Net
- String
- Integer
- Float
- Boolean
- Array
- Object
- NULL
- Resource
PHP String: A string just like a characters and a string can be any text inside quotes. You can use single or double quotes.
<?php
$a = “Hello Mom and dad!”;
echo $a;
?>
PHP Integer: Integer is a number value for example 1233.
<?php
$a = 1225;
var_dump($a);
?>
PHP Float: A float (floating point number) is a number with a decimal point.
<?php
$a = 14.25;
var_dump($a);
?>
PHP Boolean: A Boolean represents two possible states: TRUE or FALSE..
<?php
$a = true;
$b = false;
?>
PHP Array:
<?php
$alphabets = array(“A”,”B”,”C”);
var_dump($alphabets );
?>
PHP Object:
<?php
class Alphabets{
function Alphabets() {
$this->character= “A”;
}
}
// create an object
$obj = new Alphabets();
// show object properties
echo $obj ->character;
?>
PHP Null:
Null is a special data type which can have only one value: NULL.
<?php
$a = “Hello india!”;
$a = null;
var_dump($a);
?>