PHP - function_exists
Trieda
Metóda - function_exists
(PHP 4, PHP 5, PHP 7)
Checks whether a specified function exists, including user-defined functions.
Note: Some functions can exist based on a result returned by this function, but could not be unusable due to compile-time or run-time configuration of the PHP interpreter. These can be e.g. image manipulation functions.
Procedurálne
- function function_exists (string $function_name) : bool
Parametre
| Názov | Dátový typ | Predvolená hodnota | Popis |
|---|---|---|---|
| $function_name | string | The name of the function as |
Mávratovej hodnoty
Vracia: bool
Returns true if the specified function exists and is a
function.
Note: This function returns false for
constructs which aren't functions, for example include_once or
echo.
Príklady
<?php
echo function_exists('implode') ? 'Function exists.' : 'Function does not exist.'; // Output: 'Function exists.'
echo function_exists('echo') ? 'Function exists.' : 'Function does not exist.'; // Output: 'Function does not exist.'
echo function_exists('nonexistentFunction') ? 'Function exists.' : 'Function does not exist.'; // Output: 'Function does not exist.'
Súvisiace manuály
- function class_exists (string $class_name, bool $autoload = true) : bool
- function get_defined_functions (bool $exclude_disabled = FALSE) : array
