Open In App

What are the Basic Data Types in PHP ?

Last Updated : 09 Feb, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

In PHP, Basic Data Types include integers for whole numbers, floats for decimal values, strings for textual data, booleans representing true or false, arrays for storing multiple values, objects for user-defined data structures, and null for indicating the absence of a value. Understanding these data types is essential for effective data handling and manipulation in PHP scripts

Integer

PHP Integer represents whole numbers without decimal points.

Example: 
$num = 10;

Float (Floating Point Number or Double)

Represents numbers with a fractional component.

$floatnum = 3.14;  

String

Represents sequences of characters, enclosed within single (”) or double (“”) quotes.

$name = "John Doe";

Boolean

Represents a logical value, either true or false.

$is_active = true;

Array

Represents a collection of elements, each identified by a key.

$fruits = array("apple", "banana", "orange");

Object

Represents instances of user-defined classes, encapsulating data and functionality.

Example: 
$objectVariable = new stdClass();

Null

Represents a variable with no value assigned.

$variable = null;

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads