A WordPress-centric search engine for devs and theme authors



is_countable ›

Since4.9.6
Deprecatedn/a
is_countable ( $var )
Parameters:
  • (mixed) $var The value to check.
    Required: Yes
Returns:
  • (bool) True if `$var` is countable, false otherwise.
Defined at:
Codex:

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.



Source

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