Base de conhecimentoCentro de Exames
PT · PTPortuguês (Portugal)
Escolher idioma13

CKTIS / PHP

is_callable()

Verifica se um valor pode ser chamado no âmbito atual.

Versão: PHP 8.4; repository runtime, production runtime not attested

Sintaxe

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

Verifica se um valor pode ser chamado no âmbito atual. Com syntax_only, um nome bem formado de uma função inexistente pode passar. O terceiro argumento recebe o nome do destino. Antes da chamada use a verificação completa.

Assinatura

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

Saída do exemplo

[true,"strlen",true,false]

Exemplos

<?php
$ok = is_callable("strlen", false, $name);
echo json_encode([$ok, $name, is_callable("missing_fn_204", true), is_callable("missing_fn_204")]);

Resultado

[true,"strlen",true,false]

Fontes