8 data types in PHP

【Foreword】

    This article mainly summarizes the 8 data types of PHP

 

【main body】

    In PHP, a total of eight primitive data types are supported: they are four scalar types, boolean (boolean), integer (integer), float (float) and string (string); two conforming types, array (array) and object (object); two special types, resource (resource) and null value (null).

    The data type of a variable in PHP is usually not set by the programmer. To be precise, it is determined by PHP at runtime according to the context in which the variable is used. Simply put, we do not need to set the data type of the variable. PHP will Automatic Identification.

 

(1) Four scalar data types

①boolean (Boolean)

Also called bool type, there are only two values, true or false, it is not case sensitive

②string (string type)

A string is a contiguous sequence of characters, consisting of numbers, letters, and symbols.

③integer (integer)

Integer 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 both integers and decimals.

 

(2) Two conforming data types

①array (array)

An array is a combination of a set of data, which combines a series of arrays to form an operable whole.

②object (object)

Object is an entity used to describe objective things in the system, and 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.

 

(3) Two special types

①resource

A resource is a special type of variable that holds a reference to an external resource: such as an open file, database connection, graphics canvas area, etc.

②null value (null)

A null value, as it's named, means no value, which means that no value is set for the variable.

 

 

 

 

 

 

 

 

.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326112164&siteId=291194637
Recommended