is_countable

(PHP 7 >= 7.3.0)

is_countable Verify that the contents of a variable is a countable value

说锟斤拷

is_countable ( mixed $var ) : bool

Verify that the contents of a variable is an array or an object implementing Countable

锟斤拷锟斤拷

var

The value to check

锟斤拷锟斤拷值

Returns TRUE if var is countable, FALSE otherwise.

锟斤拷锟斤拷锟斤拷志

锟芥本 说锟斤拷
7.3.0 is_countable() has been added.

锟斤拷锟斤拷

Example #1 is_countable() examples

<?php
var_dump
(is_countable([123])); // bool(true)
var_dump(is_countable(new ArrayIterator(['foo''bar''baz']))); // bool(true)
var_dump(is_countable(new ArrayIterator())); // bool(true)
var_dump(is_countable(new stdClass())); // bool(false)

锟轿硷拷

  • is_array() - 锟斤拷锟斤拷锟斤拷锟角凤拷锟斤拷锟斤拷锟斤拷
  • is_object() - 锟斤拷锟斤拷锟斤拷锟角凤拷锟斤拷一锟斤拷锟斤拷锟斤拷
  • is_iterable() - Verify that the contents of a variable is an iterable value
  • is_bool() - 锟斤拷锟斤拷锟斤拷锟角凤拷锟角诧拷锟斤拷锟斤拷