PHP Data Type-
Data Types defines the type of data a variable can store. PHP supports total eight primitive data types:
Notation | Preceded with | Example |
---|---|---|
Decimal | 128 | |
Hexadecimal | 0x | 0x80 |
Octal | 0 | 0200 |
Binary | 0b | 0b10000000 |
int(123) int(-123) int(26) int(83)
A float (floating point number) is a number with a decimal point or a number in exponential form.
Floating point is also known as "floats", "doubles", or "real numbers".
It Can hold numbers containing fractional or decimal(2.56, 1.24, 7E-10) part including positive and negative numbers. By default, the variables add a minimum number of decimal places.
float(1.234) float(10200) float(4.0E-10)
A string is a sequence of characters, like "Welcome to aimtocode!". A string can be any text inside quotes. You can use single or double quotes
A string also supports and hold letters, numbers, and special characters and it can be as large as up to 2GB (2147483647 bytes maximum).
Well come to aimtocode! Hope you enjoy learning! stay here, learn more
A Boolean Data Type represents two possible states either (1) TRUE or (0) FALSE.
A Successfully done event returns true and unsuccessful event returns false.
bool(true)
An array is a variable that can hold more than one value at a time. It is useful to aggregate a series of related items together
An Array is also knwon as compound data-type which can store multiple values of same data type.
An Array can be declared in two way.
array(3) { [0]=> string(3) "Red" [1]=> string(5) "Green" [2]=> string(4) "Blue" } array(3) { ["Red"]=> string(7) "#ff0000" ["Green"]=> string(7) "#00ff00" ["Blue"]=> string(7) "#0000ff" }
An object is a particular instance of a class where it can be a combination of variables, functions, and data structures.
Objects are created based on this template via the new keyword.
Every object instance is completely independent, with its own properties and methods, and thus can be manipulated independently of other objects of the same class.
aimtocode
A resource is a special variable, holding a reference to an external resource, It typically hold special handlers to opened files and database connections.
resource(2) of type (stream)
Null Data Type represents a variable with no value
Null is a special data type which can have only one value: NULL.
If a variable is created without a value, it is automatically assigned a value of NULL.
NULL