Is a static class member not restored after session reload?
am 19.01.2008 20:40:28 von Gert KokI'd like to use 3 types of objects, which have a kind of
availability-check as a static object in their parent class.
After page reload the initialised member is NULL
Is this a PHP 5.2.5 feature or am I missing something?
------------------------------------------------
First page in a session:
------------------------------------------------
session_start();
class Checker {
function check () {
echo 'OK';
}
}
class Common {
protected static $checker;
}
class Special extends Common {
static function setChecker( ) {
parent::$checker = new Checker();
}
function show() {
echo parent::$checker->check(); <-- error !
}
}
Special::setChecker ( );
$_SESSION['b'] = new Special();
$_SESSION['b']->show();
OK
------------------------------------------------
second page in same session:
------------------------------------------------
(after start of session with class definitions)
$_SESSION['b']->show();
Fatal error: Call to a member function check() on a non-object
on the indicated line