CKTIS / PHP
is_callable()
Check whether a value can be called from the current scope.
Version: PHP 8.4; repository runtime, production runtime not attested
Syntax
is_callable(mixed $value, bool $syntax_only = false, ?string &$callable_name = null): boolCheck whether a value can be called from the current scope. With syntax_only enabled, a plausible name can pass even when the function does not exist. The optional third argument receives the callable name. Use the ordinary check before invoking a callback.
Signature
is_callable(mixed $value, bool $syntax_only = false, ?string &$callable_name = null): bool
Example output
[true,"strlen",true,false]
Examples
<?php
$ok = is_callable("strlen", false, $name);
echo json_encode([$ok, $name, is_callable("missing_fn_204", true), is_callable("missing_fn_204")]);
Result
[true,"strlen",true,false]