Documentation Index

A THIS Module

Modules

THIS calls some PHP source files "modules". These files have some internal data that it, and it alone, manages. Modules do not use global data but have a single function that has static data.

There is no global data. There are no classes. Everything is a function call. It is as simple as can be.

Module data initializes in one of three ways:

  • When the module is included.
  • Right after INDEX.PHP has included all files.
  • When the module's entry point is first called.

The net result is that there are no include file dependencies. INDEX.PHP simply includes all files in the MOD/ directory.

Initialization

A module can self-initialize when it's main entry point is first called. This is the case of the system data functions config() and html().

A module can self-initialize on inclusion by calling it's own initialize function itself, which is usually the module name preceded by an underscore, _module(). Keeping the code in a function is simply to not have to worry about polluting the global namespace.

A module can also have a function with the name _config_module(). A list of these functions is created as the modules are included. After all source files have been included, these initialization functions are called.

Since all files have been included before a modules' initialization function gets called, each initialization function has the full code base available to it. This is not perfect, however, in that no initialization function can be aware of the state of any other module.