CKTIS / PHP
function_exists()
Verifica a existência de uma função interna ou definida pelo utilizador sem distinguir maiúsculas.
Versão: PHP 8.4; repository runtime, production runtime not attested
Sintaxe
function_exists(string $function): boolVerifica a existência de uma função interna ou definida pelo utilizador sem distinguir maiúsculas. Construções da linguagem como echo não são funções. Para procurar num espaço de nomes indique o nome qualificado.
Assinatura
function_exists(string $function): bool
Saída do exemplo
[true,true,false]
Exemplos
<?php
namespace Shop;
function total() { return 5; }
echo json_encode([function_exists(__NAMESPACE__ . "\\TOTAL"),function_exists("strlen"),function_exists("echo")]);
Resultado
[true,true,false]