Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

function_exists

Description

The function_exists of Function Handling for PHP return true if the given function has been defined.

Syntax

function_exists(
    string $function
): bool

Parameters

function

The function name, as a string.

Return

Returns true if function exists and is a function, false otherwise.

NOTE: This function will return false for constructs, such as include_once and echo.

Examples

1 · function

<?

function myfunction()
{
}

$function = "myfunction";

$return = function_exists($function);

var_export($return);

?>
true

2 · namespace

<?

namespace mynamespace;

function myfunction()
{
}

$function = __NAMESPACE__ . "\myfunction";

$return = function_exists($function);

var_export($return);

?>
true
HomeMenu