call_user_func_array
<<<
call_user_func create_function
>>>

7.33 Fonctions
7 Index des fonctions
 Manuel PHP

. Introduction
. Pré-requis
. Installation
. Configuration à l'exécution
. Constantes prédefinies
. call_user_func_array
->call_user_func
. create_function
. func_get_arg
. func_get_args
. func_num_args
. function_exists
. get_defined_functions
. register_shutdown_function
. register_tick_function
. unregister_tick_function

7.33.7 call_user_func() Appelle une fonction utilisateur

[ Exemples avec call_user_func ]   PHP 3>= 3.0.3, PHP 4

mixed  call_user_func ( callback   function , mixed   parameter , mixed   ... )

call_user_func appelle la fonction utilisateur function_name , et lui passe les paramètres parameter .
Exemple avec call_user_func

<?php
  
function barbier ($type) {
    print
"Vous vouliez une coupe $type, pas de problème";
  }
  
  
call_user_func('barbier', "à la one again");
  
call_user_func('barbier', "militaire");
  
call_user_func('barbier', "au bol");
?>

Les méthodes d'objets peuvent être appelées statiquement en passant array($objectname, $methodname) au paramètre function .
Exemple avec call_user_func et une méthode de classe

<?php
class maclasse {
  function
dit_bonjour() {
    print
"Bonjour!\n";
  }
}

$classname = "maclasse";

call_user_func(array($classname,'dit_bonjour'));
?>

Voir aussi call_user_func_array , call_user_method et call_user_method_array .

<< call_user_func >>
call_user_func_array Fonctions create_function