about a piece of code from drupal 3.0.x

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
hi all
i don't understand this function .if someone help me explain it ,i
would appreciate
the code:

// invoke hook $hook of module $name with optional arguments:
function module_invoke($name, $hook, $a1 = NULL, $a2 = NULL) {
  $function = $name ."_". $hook;
  if (function_exists($function)) {
    return $function($a1, $a2);

what is it would return  ? why write $function( $a1 , $a2);?

Re: about a piece of code from drupal 3.0.x

El 10/11/2011 9:43, zhang yun escribió/wrote:
Quoted text here. Click to load it

The feature is called "variable functions" and it's explained at:


Apparently, the Drupal module API allows to implement certain
functionalities in modules by writing a function with a name in a
certain format:


This function tests whether such function exists for a given module and
calls the function if it's available.

-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com

Site Timeline