• PHP Video Tutorials

PHP - is_countable() Function


Advertisements

Definition and Usage

The function is_countable() is used to check whether the contents of the variable is a countable value.

Syntax

bool is_countable ( mixed $value )

Parameters

Sr.No Parameter & Description
1

value

The value which needs to be checked

Return Values

This function returns boolean value true if the value is countable, else returns false.

Dependencies

PHP 7.3 and above

Example

Following example demonstrates return values with different types of variables −

<?php
   var_dump(is_countable([1, 2, 3])); // bool(true)
   var_dump(is_countable(new ArrayIterator(['a', 'b', 'c']))); // bool(true)
   var_dump(is_countable(new ArrayIterator())); // bool(true)
   var_dump(is_countable(new stdClass())); // bool(false)
   var_dump(is_countable("tutorialspoint")); // bool(false)
?>

Output

This will produce following result −

bool(true)
bool(true)
bool(true)
bool(false)
bool(false)
php_variable_handling_functions.htm

Useful Video Courses


Video

PHP Online Training

45 Lectures 9 hours

Malhar Lathkar

Video

Become PHP Facebook Developer: Password-Less Authentication

34 Lectures 4 hours

Syed Raza

Video

Ultimate PHP & MySQL Web Development Course & OOP Coding

84 Lectures 5.5 hours

Frahaan Hussain

Video

Learn PHP from Scratch

17 Lectures 1 hours

Nivedita Jain

Video

E Commerce Website Development In PHP With PDO

100 Lectures 34 hours

Azaz Patel

Video

PHP in Telugu

43 Lectures 5.5 hours

Vijay Kumar Parvatha Reddy

Advertisements