search
Homephp教程php手册PHP 判断变量类型实现代码_php基础

PHP 包括几个函数可以判断变量的类型,例如:gettype(),is_array(),is_float(),is_int(),is_object() 和 is_string()。

复制代码 代码如下:

$s = "this is a string";
$i = 9;
$arr = array(2,4,6);
is_string($s); //返回TRUE,表示$s是一个字符串变量
is_string($i); //返回FALSE,表示$i不是一个字符串变量
is_array($arr); //返回TRUE,表示$arr是一个数组
is_array($s); //返回FALSE,表示$s不是一个数组
$str = "this is a string";
$int = 9;
$bool = FALSE;
echo "\$str的类型是:".gettype($str);
echo "
";
echo "
";
echo "\$int的类型是:".gettype($int);
echo "
";
echo "
";
echo "\$bool的类型是:".gettype($bool);
?>
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

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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

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.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment