charger_fonction

This charger_fonction() (translation: load_function()) function is used to retrieve the name of an overloadable SPIP function. Whenever an internal function with a _dist() suffix is overloaded (by recreating it without that suffix), or whenever all of a file that contains such a function is overloaded, then the correct function to be run must be retrievable at the time that that function is to be executed. This is what the charger_fonction() does. It returns the correct name of the function to be executed.
$ma_fonction = charger_fonction('my_function','directory');
$ma_fonction();
{{{The searching principle}}} The function operates as follows: -* if the directory_my_function function has already been declared, then that function is returned, -* else directory_my_function_dist, -* else try to load a file called directory/my_function.php then -* return directory/my_function if it exists, -* else directory/my_function_dist, -* else return false.

Example

Send an email:
$envoyer_mail = charger_fonction('envoyer_mail', 'inc');
$envoyer_mail($email_address, $subject, $text_body);

Author Mark Baber Published : Updated : 29/05/10

Translations : English, français, Nederlands