Reason for using a class (was Re: [Pmwiki-users] Re: Request for)

Patrick R. Michaud pmichaud
Fri Jul 16 20:16:28 CDT 2004


On Fri, Jul 16, 2004 at 10:50:01PM +0200, chr at home.se wrote:
> I'd like to be able to have a separate namespace for variables that are
> "global" to my plugin, so that they wont come into conflict with variables
> from other plugins.
>
> Is there some other way than using a class to fix this?

Ummm, you can use a variable name prefix, or you can use an array.
For example, all of the variables in mailposts.php are prefixed with
$MailPosts, as in $MailPostsTo, $MailPostsDelay, $MailPostsSquelch, etc.

Another way to do it would be to use an array, as in $MailPosts['To'],
$MailPosts['Delay'], etc.  However, note doing it as arrays, as well
as using classes, prevents the variables from ever being used in $...Fmt
strings, which may or may not be desirable depending on the application.

Pm



More information about the pmwiki-users mailing list