[development] module_exists vs. functions_exists?

Damien damz at prealable.org
Wed Jun 25 16:43:26 UTC 2008


On Wed, Jun 25, 2008 at 6:14 PM, Aaron Winborn <winborn at advomatic.com>
wrote:

> mymod.module
> $mymod_bar = module_call('optionalmod', 'cool_function', $args);
> if (isset($mymod_bar)) {
>  $mymod_foo = module_invoke('urmod', 'some_hook', $mymod_bar);
> }
>

Again, I do not see the point of module_call if you can do:

if (drupal_function_exists('cool_function')) {
  $mymod_bar = cool_function($args);
}

Advantages?
- It is cleaner and faster
- It does not add a new level of indirection
- It makes reference tracking works (such as what is done on api.drupal.org)

Moreover, you can do correct error management:

if (drupal_function_exists()) {
}
else {
}

Damien
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20080625/64c70b2f/attachment.htm 


More information about the development mailing list