W3cubDocs

/WordPress

is_countable( mixed $var )

Polyfill for is_countable() function added in PHP 7.3.

Description

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

Parameters

$var

(mixed) (Required) The value to check.

Return

(bool) True if $var is countable, false otherwise.

Source

File: wp-includes/compat.php

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

Changelog

Version Description
4.9.6 Introduced.

© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/is_countable