I have a static class with no constructor which I intend no one inheriting from and it having static values. However, the class fails to instantiate because the static instantiating method refuses to run. I have this
$all_users = //array of objects;
$username = "vain_glories";
class pageOwner {
static $instance = NULL;
static function assignStatic() {
var_dump($_GLOBALS['all_users']);
if (is_null(self::$instance)) {
foreach($all_users as $user=>$usernames) {
if ($usernames == $username) {
echo "ASSIGNED";
self::$instance = $user;
return;
}
else echo "NOT ASSIGNED";
}
}
}
}
pageOwner::assignStatic();
I have moved that var_dump
function both below that line, and also
tried dumping it without using globals but nothing dumps; it simply
outputs NULL
and infringes every other output on the page. My error
log reports nothing as well. What could be wrong?
Update This example originates from a webshop where the format and exchange rate are decoupled from the text, which is stored in a cache file. With this solution, it is possible to use caching techniques and still have a dynamic exchange rate.