PHP is_countable() Function

P
PHP is_double() Function
PHP is_callable() Function

In this article, you will learn how to check if a variable contains a countable value or not in PHP. The is_countable() function in PHP checks whether the contents of a variable are a countable value or not.

This function returns true (1) if the variable is countable, otherwise it returns false/nothing.

what is the syntax of the IS_COUNTABLE() function in php?

is_countable(variable);
ParameterDescription
variableRequired. Specifies the variable to check
PHP is_countable() method

examples of the IS_COUNTABLE() function

Example 1. In this example, we check whether the contents of a variable is a countable value or not.

<?php
$a = "Hello";
echo "a is " . is_countable($a) . "<br>";

$b = array("red", "green", "blue");
echo "b is " . is_countable($b) . "<br>";

$c = array("Peter"=>"35", "Ben"=>"37", "Joe"=>"43");
echo "c is " . is_countable($c) . "<br>";

$d = [1, 2, 3];
echo "d is " . is_countable($d) . "<br>";
?>
PHP is_double() Function
PHP is_callable() Function

Add comment

Tutor Network

Share this

Learn PHP from A to Z