Different Data Types In PHP

Data Types In PHP

What is PHP

In 1994, PHP was developed by Rasmus Lerdorf. It is a scripting language that can be deployed on the server side. The main advantage of PHP is open-source. For web development, PHP is well fitted. Hence, it is utilized to create dynamic web applications. 

PHP Online Course supports PHP learners to build dynamic applications under the guidance of real-time mentors.

The following points are important about PHP: 

  • PHP doesn’t require compilation.
  • Compares with other Scripting languages. PHP is quicker.
  • PHP is used to handle the dynamic content of the web application.
  • PHP be able to integrate into HTML.
  • PHP is an object-oriented and interpreted scripting language that is an easy-to-learn.

PHP is majorly categorized into three different data type in php and it supports 8 primitive data types.

  1. Predefined Types
  2. User-defined
  3. Special Types

Predefined Types

It comprises a single value but this value contains 3 Predefined

 data types.

  1. string
  2. Integer
  3. boolean in php

Compound Types

It comprises 2 compound data values.

  1. array
  2. object

Special Types

 PHP Contains 2 special data types.

  1. Resource
  2. NULL

PHP String Data Type

It is a non-numeric data type. It contains only alphabets and special characters.

String values should be closed in single quotes or double quotes. But both are handled separately. To understand this, refer this instance below:



    $company = “FITA Academy“;  

    //both single and double quote statements will treat different  

    echo “Hello $PHP Tutorial”;  

    echo “</br>”;  

    echo ‘Hello $PHP Tutorial’;  



FITA Academy

Hello $PHP Tutorial

To know more about different Data Type In PHP, Check PHP Training in Chennai.

Boolean In PHP Data Type

It’s the most uncomplicated data type that acts like a switch button. It includes two states: TRUE (1) or FALSE (0). It is frequently used depending on statements. If the statement is correct, it returns TRUE otherwise FALSE.



    if (TRUE)  

        echo “The statement is TRUE.”;  

    if (FALSE)  

        echo “The statement is FALSE.”;  



The statement is TRUE.

PHP Array Data Type

It is a compound types and comprises many values of identical data type in a separate variable.



    $cars = array (“Honda”, “BMW”, “Toyota”);  

    var_dump($cars); //the var_dump() function returns the datatype and values  

    echo “</br>”;  

    echo “Array Element1: $cars[0] </br>”;  

    echo “Array Element2: $cars[1] </br>”;  

    echo “Array Element3: $cars[2] </br>”;  



array(3) { [0]=> string(13) “Honda” [1]=> string(6) “BMW” [2]=> string(3) “Toyota” }

Array Element1: Honda

Array Element2:BMW

Array Element3:Toyota

PHP object Data Type

Objects data types are the examples of user-specified classes which can save values and functions. They should be clearly stated.



     class car {  

          function model() {  

               $model_name = “Maruti Suzuki”;  

               echo “Car Model: ” .$model_name;  



     $obj = new Car();  

     $obj -> model();  



Car Model: Maruti Suzuki


In this blog, we discussed different Data Type with examples. It will be useful for learners and beginners in PHP. If you plan to get training in PHP, PHP Training in Coimbatore is the right destination