A THIS Module
For THIS, a module is a PHP source file that has some internal data that it, and it alone, manages. Modules do not use global data but have a single function that has static data. This static data is in a function of the module's name with a leading underscore. After all PHP source files have been included these "init" functions are called (if they exist) and the static data is initialized.
There is no global data. There are no classes. Everything is a function call. It is as simple as simple.
The net result is that there are few include file dependencies. INDEX.PHP simply includes all files in the MOD
directory. There is no need to maintain a list of include statements.
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. But in the case of the system data functions config()
and html()
, they just initialize on first call and can be called by anyone in any order.
If a module must be initialized before others, such as ERROR.PHP and RULES.PHP, it must be in the base directory and explicitly included by INDEX.PHP and self-initialize (by a call to it's own _module()
function).