search
HomeBackend DevelopmentPHP TutorialData Types PHP Section 2 Numeric Data Types

PHP supports 8 basic data types.

4 Point type, also called

double
  • ) string
  • (string) Two composite types:
  • array (array) object
  • (object) Finally there are two special types:

    resource
  •  (resource) NULL
  •  (NULL) b
oolean

Data type:
  • The value can only be True or False. When other types are converted to boolean types, the following values ​​are considered FALSE
  • : the Boolean
  • value
FALSE

itself the whole type value 0 (zero)
the
float

value 0.0 (zero)

empty string, and

string
    "0"
  • an array containing no elements
  • An object that does not include any member variables (only applicable to PHP 4.0)
  • Special type NULL (including variables that have not been set)
  • generated from an XML document without any tags (tags) SimpleXML All other values ​​for an object are considered
  • TRUE (including any resources ).
  • integer data type:
  • Integer values ​​can be represented in decimal, hexadecimal or octal, and can be preceded by an optional sign (- or +). The octal representation must be preceded by 0 (zero), and the hexadecimal representation must be preceded by
  • 0x. The word length of integers is platform-dependent, although the usual maximum is about two billion (32-bit signed). PHP does not support unsigned integers. The word length of the
  • Integer

value can be represented by the constant PHP_INT_SIZE. Since PHP 4.4.0 and PHP 5.0.5, the maximum value can be represented by the constant PHP_INT_MAX.
If a given number exceeds the range of

integer

, it will be interpreted as

float

. Similarly, if the result of the operation exceeds the range of integer

,

float will also be returned. There is no operator for integer division in PHP. 1/2 yields

float

0.5. You can always discard the decimal part, or use the round() function. To explicitly convert a value to integer, use (int) or

(integer)

cast. Most of the time though, no casting is necessary, because when an operator, function, or control flow requires an integer parameter, the value is automatically converted. You can also use the function intval() to convert a value into an integer. Converting

from a

boolean , FALSE will yield 0 (zero), TRUE will yield 1 (one).

float data type

The word length of floating point numbers is platform-dependent, although typically the maximum value is 1.8e308 with a precision of 14 decimal digits (64-bit IEEE format).

Apparently simple decimal fractions like 0.1 or 0.7 cannot be converted to the internal binary format without losing a little precision. This can lead to confusing results: for example, floor((0.1+0.7)*10) will usually return 7 instead of the expected 8, because the internal representation of the result is actually something like 7. 9.

This is related to the fact that it is impossible to express certain decimal fractions accurately with a finite number of digits. For example, decimal 1/3 becomes 0.3.

So never believe that the floating point number result is accurate to the last digit, and never compare whether two floating point numbers are equal. If you really need higher precision, you should use arbitrary precision math functions or the gmp function.

The above introduces the data types. PHP Section 2: Numeric type of data types, including the content of data types. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement
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
dint是什么数据类型dint是什么数据类型Sep 05, 2022 am 11:05 AM

dint是带符号位的32位整数类型;dint的表示方法及范围是“L#-2147483648~L#+2147483647”,定义为双整数或长整数,字节是电脑里的数据量单位,在计算机中,数据只用0和1这种表现形式。

Python时间序列数据操作的常用方法总结Python时间序列数据操作的常用方法总结Apr 24, 2023 pm 10:22 PM

时间序列数据是一种在一段时间内收集的数据类型,它通常用于金融、经济学和气象学等领域,经常通过分析来了解随着时间的推移的趋势和模式Pandas是Python中一个强大且流行的数据操作库,特别适合处理时间序列数据。它提供了一系列工具和函数可以轻松加载、操作和分析时间序列数据。在本文中,我们介绍时间序列数据的索引和切片、重新采样和滚动窗口计算以及其他有用的常见操作,这些都是使用Pandas操作时间序列数据的关键技术。数据类型Python在Python中,没有专门用于表示日期的内置数据类型。一般情况下都

mysql性别用什么类型mysql性别用什么类型Jun 13, 2023 am 11:33 AM

MySQL性别采用多种数据类型来表示性别字段,例如CHAR、ENUM等,最终采用哪种类型,取决于实际需求以及数据存储的大小和性能。

java的数据类型有哪些java的数据类型有哪些Jan 30, 2024 pm 03:23 PM

java数据类型:1、整型;2、浮点型;3、字符型;4、布尔型;5、其他数据类型;6、引用类型;7、原始类型与封装类;8、自动装箱与拆箱;9、可变参数;10、注解;11、枚举;12、原始类型和引用类型的选择。Java是一种强类型语言,因此每种数据都有其固定类型。

decimal是什么类型decimal是什么类型Mar 18, 2021 pm 04:03 PM

decimal是MySQL中存在的精准数据类型,语法格式“DECIMAL(M,D)”。其中,M是数字的最大数(精度),其范围为“1~65”,默认值是10;D是小数点右侧数字的数目(标度),其范围是“0~30”,但不得超过M。

MySQL数据类型详解:你需要知道的知识点MySQL数据类型详解:你需要知道的知识点Jun 15, 2023 am 08:56 AM

MySQL是世界上最流行的关系型数据库管理系统之一,因其可靠性、高安全性、高扩展性以及相对低的成本而得到了广泛应用。MySQL的数据类型定义了各种数据类型的存储方式,是MySQL的重要组成部分。本文将详解MySQL的数据类型,以及在实际应用中需要注意的一些知识点。一、MySQL的数据类型分类MySQL的数据类型可以分为以下几类:整数类型:包括TINYINT、

表中字段的数据类型有哪些表中字段的数据类型有哪些Jan 19, 2021 am 10:18 AM

表中字段的数据类型有:1、二进制类型,包括Binary、Varbinary、Image;2、字符串类型,包括CHAR、VARCHAR、TEXT等;3、Unicode数据类型,包括Nchar,Nvarchar和Ntext;4、日期和时间数据类型,包括DATE、TIME、YEAR等;5、数值数据类型,包括INT、FLOAT、BIGINT等;6、货币数据类型;7、特殊数据类型等等。

PHP8中支持的新数据类型可以让你的代码变得更加清新PHP8中支持的新数据类型可以让你的代码变得更加清新Jun 21, 2023 am 11:20 AM

随着PHP8的发布,这个流行的编程语言引入了新的数据类型,这些新类型可以大大简化代码并提高代码的可读性。在本文中,我们将介绍PHP8中的四种新类型:联合类型、命名参数、只读属性和允许为空的属性,并解释它们如何为开发者带来更好的编程体验。联合类型联合类型是PHP8中引入的一种新类型,它可以让开发者在一个变量中存储多种不同类型的值。例如,一个变量可以

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

Repo: How To Revive Teammates
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.