WordPress at Your Fingertips

is_countable() WP 1.0

Polyfill for is_countable() function added in PHP 7.3.

Verify that the content of a variable is an array or an object implementing the Countable interface.

1 time — 0.000001 sec (speed of light) | 50000 times — 0.01 sec (speed of light) | PHP 7.1.11, WP 4.9.8

No Hooks.

Return

true|false. True if $var is countable, false otherwise.

Usage

is_countable( $var );
$var(mixed) (required)
The value to check.

Changelog

Since 4.9.6 Introduced.

Code of is_countable() WP 5.7.2

<?php
function is_countable( $var ) {
	return ( is_array( $var )
		|| $var instanceof Countable
		|| $var instanceof SimpleXMLElement
		|| $var instanceof ResourceBundle
	);
}

From tag: Very rarely used (trash)

No comments
    Log In