array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'fr', ), 'this' => array ( 0 => 'function.function-exists.php', 1 => 'function_exists', ), 'up' => array ( 0 => 'ref.funchand.php', 1 => 'Fonctions sur la gestion des fonctions', ), 'prev' => array ( 0 => 'function.func-num-args.php', 1 => 'func_num_args', ), 'next' => array ( 0 => 'function.get-defined-functions.php', 1 => 'get_defined_functions', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'fr', 'path' => 'reference/funchand/functions/function-exists.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4, PHP 5, PHP 7, PHP 8)
function_exists — Indique si une fonction est définie
Vérifie la liste des fonctions définies par l'utilisateur ainsi que celles
internes à php afin d'y trouver function
.
Retourne true
si la fonction function
existe et est une fonction, false
sinon.
Note:
Notez également que function_exists() retournera
false
pour les instructions comme include_once et echo.
Exemple #1 Exemple avec function_exists()
<?php
if (function_exists('imap_open')) {
echo "Les fonctions IMAP sont disponibles.<br />\n";
} else {
echo "Les fonctions IMAP ne sont pas disponibles.<br />\n";
}
?>
Note:
Un nom de fonction peut exister même si la fonction elle-même n'est pas utilisable à cause d'une configuration ou d'une option de compilation (avec les fonctions image par exemple).