Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the scalar data types in php

Shulou Source: shulou.com Published: 2022-06-02 04:19:21 10月03日 Update

This article is about what scalar data types are in php. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

The data types of PHP can be divided into three categories: scalar data types, compound data types and special data types.

Among them, the scalar data type is the most basic unit of the data structure, which can only store one data. There are four types of scalar data in PHP, as shown in the following table:

Type function

Boolean (Boolean) the simplest data type with only two values: true (true) / false (false)

A string (string) string is a continuous sequence of characters

Integer (integer) integers contain all integers, either positive or negative

Float is also used to represent numbers, unlike integers, it can also be used to represent decimals and exponents in addition to integers.

1. Boolean (boolean)

Boolean is one of the most commonly used data types in PHP, which holds a true value or false value, where true and false are the internal keywords of php. To set a Boolean variable, simply assign true or false to the variable. In php, not only Boolean values are false, but also non-Boolean values are considered to be false in some special cases. For example, 0, an empty string and only an array that declares no assignment.

2. Character string (string)

A string is a continuous sequence of strings consisting of numbers, letters, and symbols. Each character in the string takes up only one byte. There are three ways to define a string, single quotation marks, double quotation marks, and delimiters

Tags: Type data character string variable quotation mark integer number floating point decimal Boolean mode storage output code scalar result run special between Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Linux Shulou Information vpn Xiaomi