Menu

Need MCA Or B.tech College Project Contact Us: +91 9437911966 (Whatsapp) Students Tutorial


PHP Data type with example

We can assign different type of data to a variable. Data type means the various type of data that we assign to a variable.

PHP support various type of data type and all are also different from each other.

Below are the list of data type :

  1. String
  2. Integer
  3. Float (floating point numbers - also called double)
  4. Boolean
  5. Array
  6. Object
  7. NULL
  8. Resource

PHP String

A string can have letters, numbers, special characters and arithmetic values or combination of all.

Example

Example

<!DOCTYPE html>
<html>
<body>
<?php 
$a = "Hello world!";
$b = 'Hello world!';
echo $a;
echo "<br>"; 
echo $b;
?>
</body>
</html>

You can use both single quotation or double quotation

PHP Integer

All the number without decimal point is called as integer.

Example: 100, 2000 etc.

Example

<!DOCTYPE html>
<html>
<body>
<?php  
$a = 100;
var_dump($a);
?>  
</body>
</html>

PHP Float or Double

The Float or Double data type are number with decimal point.

Example: 29.6, 30.03 etc..

Example

<!DOCTYPE html>
<html>
<body>
<?php  
$a = 29.6;
var_dump($a);
?>  
</body> </html>

PHP Boolean

HP Boolean have only two possible values either true or false.

PHP Array

PHP array is used to store multiple value in one single variable.

Example

<!DOCTYPE html>
<html>
<body>
<?php  
$name = array("Divya","Manas","Santosh");
var_dump($name);
?>  
</body>
</html>

PHP null

A variable of type null is a variable without any data.


 
 


Example

<!DOCTYPE html>
<html>
<body>
<?php
$a= NULL;
var_dump($a);
?>
</body>
</html>