PHP is_callable() Function

Beginner
5 min read
Updated: Nov 2026
3 examples
Variables

Definition

In PHP, is_callable() checks whether a value can be called like a function. It returns true for function names, closures and valid method callbacks, and false otherwise.

This is useful before you pass a callback to functions such as array_map() or call_user_func(). The function checks that the name exists and that the method is reachable from where you call it. Private methods, for example, are not callable from outside the class.

Syntax

Call is_callable() with the values you need. Start with this line.

PHP
$result = is_callable($value);
CallWhat it does
is_callable('strlen')Returns true, because strlen() is a real function.
is_callable([$object, 'method'])Returns true if the method exists and can be called from here.
is_callable($value, true, $name)Checks only the syntax and also stores the callable's name in $name.

A callable can be a function name string, a closure, an invokable object, a [$object, 'method'] pair, a 'Class::method' string or a first-class callable such as strlen(...). With the second argument set to true, PHP only checks that the value looks like a callable.

Library declarations
PHP
is_callable(mixed $value, bool $syntax_only = false, string &$callable_name = null): bool

Parameters

ParameterDescription
valueRequired. The value to check. For example a function name, a closure or an array like [$object, 'method'].
syntax_onlyOptional. When true, only the shape of the value is checked, not whether the function or method exists. The default is false.
callable_nameOptional. A variable passed by reference. PHP stores the name of the callable in it, such as Greeter::hi or Closure::__invoke.

Return Value

Return ValueDescription
booltrue if the value can be called, otherwise false.

PHP Examples

Example 1 — Functions and Closures

Test a user function, a built-in function, an arrow function and a name that does not exist.

PHP
<?php
function hello() {
    return "Hello";
}

var_dump(is_callable('hello'));
var_dump(is_callable('strlen'));
var_dump(is_callable(fn() => 1));
var_dump(is_callable('no_such_function'));

How It Works

  1. The string 'hello' matches the function we declared, so it is callable.
  2. 'strlen' is a built-in function, so it is callable too.
  3. An arrow function is a Closure object, which is always callable.
  4. 'no_such_function' does not exist, so the result is false.

Example 2 — Methods and Visibility

Methods are checked using an array or a Class::method string. Visibility matters.

PHP
<?php
class Greeter {
    public function hi() { return "Hi"; }
    public static function hello() { return "Hello"; }
    private function secret() { return "Secret"; }
}

$g = new Greeter();

var_dump(is_callable([$g, 'hi']));
var_dump(is_callable('Greeter::hello'));
var_dump(is_callable([$g, 'secret']));
var_dump(is_callable([$g, 'missing']));

How It Works

  1. [$g, 'hi'] points to a public method, so it is callable.
  2. 'Greeter::hello' is a public static method, so the string form works too.
  3. secret() is private, so it cannot be called from outside the class and the result is false.
  4. 'missing' is not declared in the class, so the result is false.

Example 3 — Syntax Only and Callable Name

The optional arguments let you check only the shape of a value and read back its name.

PHP
<?php
class Greeter {
    public function hi() { return "Hi"; }
}

is_callable([new Greeter(), 'hi'], false, $name);
echo $name, PHP_EOL;

var_dump(is_callable('Greeter::nope', true));
var_dump(is_callable('Greeter::nope'));

How It Works

  1. The third argument is passed by reference, so is_callable() writes the callable's name into $name.
  2. echo prints Greeter::hi, which is the class and method name.
  3. With syntax_only set to true, 'Greeter::nope' is accepted because it has a valid Class::method shape.
  4. Without that flag, PHP checks that the method exists, and the result is false.

Frequently Asked Questions

is_callable() returns true if a value can be called as a function. That includes function names, closures, invokable objects and valid method callbacks.
function_exists() only checks for a named function. is_callable() also handles closures, object methods, static methods and invokable objects, so it is more general.
method_exists() checks if a method is declared, even if it is private. is_callable() also checks whether you are allowed to call it from the current place, so private methods return false from outside.
When it is true, PHP only checks that the value has a valid shape, such as a string or a [class, method] pair. It does not check that the function or method exists.
Use it when a callback comes from outside your code, such as a setting or a parameter, and you want to fail early with a clear message instead of getting an error later.

Next: is_countable()

is_countable() checks whether a value can be used with count(). It returns true for arrays.

is_countable() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful