PHP Data Types
PHP supports several data types that are grouped into scalar types, compound types, and special types. Here's a breakdown:
Scalar Types
These represent single values:
-
Integer
Whole numbers, e.g.,10
,-20
,0
. -
Float (Double)
Decimal numbers, e.g.,3.14
,-0.5
. -
String
A sequence of characters, e.g.,"Hello, PHP!"
,'123'
. -
Boolean
Represents two values:true
orfalse
.
Compound Types
These hold multiple values:
-
Array
A collection of values, e.g., -
Object
An instance of a class:
Special Types
-
NULL
A variable with no value: -
Resource
A reference to an external resource (e.g., database connection or file handle):