Home > Backend Development > PHP Tutorial > Eight data types of PHP

Eight data types of PHP

怪我咯
Release: 2023-03-07 15:00:01
Original
8878 people have browsed it

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.

Eight data types of PHP 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)

The integer type is what we often call an integer, it can only be an 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.


Two consistent data types

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.


Two special types

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 "

boolean

" in a scalar data type.

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template