PHP Data types ?


PHP Data types specify the different types of data that are supported in PHP language

There are total 8 data types supported in PHP language, which are categorized into three main types:-


  1. Scalar Type:-Boolean, integer, float, string
  2. Compound Type:-Array and object
  3. Special Type:-resource and NULL

PHP Boolean

A Boolean data type can have two possible values, either True or False.
Example:-
$a=true;
$b=false;

PHP Integer

An Integer data type is used to store any non-decimal numeric value within the range -2,147,483,648 to 2,147,483,647.
Example:-
$a=34;
$b=-34;

PHP Float

Float data type is used to store any decimal numeric value. A float(floating point) value can also be either negative or positive.
Example:-
$a= 34.6;
$b=-23.6;

PHP String

String data type in PHP and in general, is a sequence of characters(or anything, it can be numbers and special characters too) enclosed within quotes. You can use single or double quotes.
Example:- $a= "shineskill";

PHP Null

NULL data type is a special data type which means nothing. It can only have one value, and that is NULL. If you create any variable and do not assign any value to it, it will automatically have NULL stored in it. Also, we can use NULL value to empty any variable.