本文整理了有关于PHP中常见的数据类型,感兴趣的朋友可以参考下
PHP 数据类型
PHP 支持八种原始类型(type)。
四种标量类型:
string(字符串)
integer(整型)
float(浮点型,,也作 double )
boolean(布尔型)
两种复合类型:
array(数组)
object(对象)
两种特殊类型:
resource(资源)
NULL(空)
查看变量类型
通过 gettype() 函数可以方便的查看某个变量的类型:
复制代码 代码如下:
(PS:T不错的PHP Q扣峮:276167802,验证:csl)
提示
由于历史原因,如果是 float 类型数据,gettype() 函数返回的是 double,而不是 float 。
如果想查看某个表达式的值和类型,请使用用 var_dump() 函数。
判断变量类型
如果想通过判断变量类型来确定下一步逻辑动作,不要使用 gettype() ,而使用 is_type 系列函数:
复制代码 代码如下:
以上是本文关于PHP 数据类型的汇总,希望本文对广大php开发者有所帮助,感谢您阅读本文。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

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.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SublimeText3 Linux new version
SublimeText3 Linux latest version

SublimeText3 Chinese version
Chinese version, very easy to use