Posted by Gert Kok on 01/19/08 19:40
I'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
[Back to original message]
|