this is not a blog

I Reckon This Must be the Place, I Reckon

Details of the architecture

Got No Class

This code has no class, as in no PHP class is defined. Instead, something like this is done:

PHP code function config($var NULL$val NULL) {
static 
$config = array();

    if (
$config === array()) {
       
$config parse_ini_file('config.ini',TRUE);
       
// fall through
   
}

    if (
$var === NULL)
        return 
$config;

    if (
$val !== NULL)
        return 
$config[$var] = $val;

    if (isset(
$config[$var]))
        return 
$config[$var];

    return 
'';
}

This way, config() has the basic class attribute of having "properties" that can be "set" and "get". With the first call to it being like a "constructor" as it self-initialises.

This simple convention eliminates entirely the use of global, something that WikiMedia code declares as "evil" while using thousands of them. sigh

The config() function can also safely recurse, i.e. the initialization code block can call itself.

This is how this code does not use any globals; e.g. config('data') is an r-value like a global value.

Though the amount of overall data is quitre small, config() and the few other data modules actually return by reference. All that needed to change was the "undefined data" return from a literal to a value:

PHP code function &config($var NULL$val NULL) {
static 
$config = array();
static 
$nul '';

   
// ...

   
return $nul;
}