[dokuwiki] Re: Global vars within plugins...

  • From: "Andreas Gohr" <andi@xxxxxxxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Mon, 28 Jul 2008 21:50:45 +0200

Hi,
> For a plugin, I'm looking to check the availability of an installed library.
> The only way I've found I can do this (anyone know another way?) is to do 
> this:

I'm not sure I understand what you are trying to do but
function_exists or class_exists should help you with that.

> Much to my surprise, this works, however I would imagine this is the
> worst possible thing you could do-- include a library from within the
> scope of a class method, right?

You should use require_once instead of include_once. The former will
add the library to the global scope, while the latter *includes* the
code exactly where it is called (inside your class member function).
Loading a library from within a function isn't a bad idea at all. It
ensures the code is only loaded when it is really needed.

Andi

-- 
splitbrain.org
-- 
DokuWiki mailing list - more info at
http://wiki.splitbrain.org/wiki:mailinglist

Other related posts: