Home > Article > Backend Development > Eight data types of PHP
Understand the data types of PHP
In PHP, a total of eight primitive data types are supported: they are 4 scalar types, boolean ( Boolean type), integer (integer type), float (floating point type) and string (string type); two conforming types, array (array) and object (object); two special types, resource and null.
The data type of variables in PHP is usually not set by the programmer. To be precise, it is determined by PHP at runtime based on the context in which the variable is used. Simply That is to say, we do not need to set the data type of the variable, PHP will automatically recognize it.
Four scalar data types
##boolean (Boolean)
Also called bool type, it has only two values, true or false, it is not case sensitive
##string (string type) A string is a continuous sequence of characters, consisting of numbers, letters and symbols.
integer (integer)
float (floating point) The floating point data type is our common decimal, which can be used to store integers. Decimals can also be stored.
array (array)
The array is A combination of a set of data, which combines a series of arrays to form an operable whole.
object (object)An object is an entity used to describe objective things in the system. It is a basic unit that constitutes the system. An object consists of a set of properties and a set of services that operate on the set of properties.
resource (resource)
The resource is a A special variable type that holds a reference to an external resource: such as an open file, database connection, graphics canvas area, etc.
Null value (null)Null value, as shown in the name, means that it has no value, which means that no value is set for the variable.
Above we have briefly understood the eight primitive data types of PHP. Later we will introduce these eight data types in detail. In the next section, we will first introduce the four "
The above is the detailed content of Eight data types of PHP. For more information, please follow other related articles on the PHP Chinese website!