What is Data Type and how many types of data type in PHP ?

PHP Data Types:

Data types define the type of data that a variable can hold. PHP provides the following built-in data types:

What is String datatype is PHP:

A sequence of characters, such as letters, numbers, and symbols, enclosed in  single or double quotes. 

$str = "Hello world!";
echo $str;

Integer datatype in PHP:

A whole number (positive, negative, or zero) without a decimal point. An integer number typically ranging between  -2,147,483,648 and 2,147,483,647. 

$x = 55;

Float datatype in PHP:

A number with a decimal point or a fractional component.

$x = 82.55;

Boolean datatype in PHP:

A value that can be either true or false.

    if (TRUE)  
        echo "This condition is TRUE.";  
    if (FALSE)  
        echo "This condition is FALSE.";  

Array Array datatype in PHP:

A collection of elements, each identified by a key, which can hold values of different data types.

$x =array("Mohan", "Ajit", "Vikash");

NULL datatype in PHP:

Its represents the absence of a value.

$x =null;

What is Object data type in PHP:

An instance of a class, which is a blueprint that defines the properties and methods of an object.

     class car {  
          function model() {  
               $model_name = "BMW";  
               echo "car Model: " .$model_name;  
     $obj = new car();  
     $obj -> model();  


car Model: BMW

Related Posts

Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x
Artificial Intelligence