-
Notifications
You must be signed in to change notification settings - Fork 1
Functions php functions
sinsunsan edited this page Nov 12, 2012
·
2 revisions
-
function_exists
Check if a function is defined before to call it (and to prevent an error if it doesn't exist
http://php.net/function_exists
- func_get_args
http://fr2.php.net/func_get_args
Permet de récupérer les arguments qui ont été passé dans la fonction sous la forme d'un tableau. S'utilise donc à l'intérieur d'une fonction.
function drupal_get_form($form_id) {
$form_state = array();
$args = func_get_args();
// Remove $form_id from the arguments.
array_shift($args);
$form_state['build_info']['args'] = $args;
return drupal_build_form($form_id, $form_state);
}
Useful to send to a function argument, without defining them
function foo() {
$args = func_get_args();
return $args;
}
foo(1,2,3)
//In this case return
array(1, 2, 3)