PHP is_bool() 函数

PHP 教程 · 2019-01-31 16:57:16

is_bool() 函数用于检测变量是否是布尔型。

PHP 版本要求:PHP 4, PHP 5, PHP 7

语法

bool is_bool ( mixed $var )

参数说明:

  • $var:要检测的变量。

返回值

如果 var 是 boolean 则返回 TRUE。

实例

实例

<?php $a = false; $b = 0; // 因为 $a 是布尔型,所以结果为 true if (is_bool($a)) { print "变量 a 是布尔型"; } // 因为 $b 不是布尔型,所以结果为 false if (is_bool($b)) { print "变量 b 是布尔型"; } ?>

输出结果为:

变量 a 是布尔型

点击查看所有 PHP 教程 文章: https://www.codercto.com/courses/l/5.html

查看所有标签

Algorithms to Live By

Algorithms to Live By

Brian Christian、Tom Griffiths / Henry Holt and Co. / 2016-4-19 / USD 30.00

A fascinating exploration of how insights from computer algorithms can be applied to our everyday lives, helping to solve common decision-making problems and illuminate the workings of the human mind ......一起来看看 《Algorithms to Live By》 这本书的介绍吧!

MD5 加密
MD5 加密

MD5 加密工具

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具