Data Type in PHP
PHP supports several data types, each designed to handle different types of values.
Here some commonly data type:
- String
- Float
- Integer
- Boolean
- Array
- Object
- Null
- Resource
- Callable
- Iterable
String
Represents sequences of characters, enclosed in single or double quote.
$name="santhosh";
Float
Represents numbers with decimal points or in exponential form.
$price=68.56;
Integer
Represents whole numbers, positive or negative, without decimal points.
$age=19;
Boolean
Represents a true or false value.
$is_logged_in= true;
Array
Represents an ordered collection of value, often used to store multiple values in a single variable.
$color =('red','blue','yellow');
Object
Represents an instance of a user-defined class. Objects can contain properties and methods.
Null
Represents a variable with no value assigned to it.
Resource
Represents a reference to an external resource, like a database connection or a file handle.
Callable
Represents a callback function, used in contexts like function callbacks or method callbacks.
Iterable
Represents collections that can be iterated over, introduced in PHP 7.1.