PHP is_iterable() 函数

PHP 教程 · 2019-01-31 18:26:40

is_numeric() 函数用于检测变量的是否是一个可迭代的值。

PHP 版本要求: PHP 7 >= 7.1.0

语法

bool is_iterable ( mixed $var )

参数说明:

  • $var:要检测的变量,可以是数组或者实现 Traversable 接口的对象。

返回值

如果指定变量是个可迭代的对象则返回 TRUE,否则返回 FALSE。

实例

实例

<?php var_dump(is_iterable([1, 2, 3])); // bool(true) var_dump(is_iterable(new ArrayIterator([1, 2, 3]))); // bool(true) var_dump(is_iterable((function () { yield 1; })())); // bool(true) var_dump(is_iterable(1)); // bool(false) var_dump(is_iterable(new stdClass())); // bool(false) ?>

输出结果为:

bool(true)
bool(true)
bool(true)
bool(false)
bool(false)

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

查看所有标签

Linux Device Drivers

Linux Device Drivers

Jonathan Corbet、Alessandro Rubini、Greg Kroah-Hartman / O'Reilly Media / 2005-2-17 / USD 39.95

Device drivers literally drive everything you're interested in--disks, monitors, keyboards, modems--everything outside the computer chip and memory. And writing device drivers is one of the few areas ......一起来看看 《Linux Device Drivers》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

在线进制转换器
在线进制转换器

各进制数互转换器

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具