468,133 Members | 1,649 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,133 developers. It's quick & easy.

Is a static class member not restored after session reload?



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
Jan 19 '08 #1
0 1077

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by fred | last post: by
1 post views Thread by Chris Bardon | last post: by
10 posts views Thread by Flare | last post: by
4 posts views Thread by Mantorok | last post: by
2 posts views Thread by james | last post: by
1 post views Thread by cobus.lombard | last post: by
7 posts views Thread by Spoon | last post: by
27 posts views Thread by didacticone | last post: by
1 post views Thread by gcdp | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.