472,978 Members | 2,406 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,978 software developers and data experts.

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 1208

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: fred | last post by:
Hi, can someone please explain to me how a static member of a class works. For example if I have: public Class1 public static Class2 myClass2 = new Class2; public static Int16 thisValue = 200;...
4
by: Wayne | last post by:
Hi, I'm new to .NET and have a question about the use of static variables vs. session variables in a web form in C#. Instead of using a session variable to hold a string to persist during...
1
by: Chris Bardon | last post by:
I'm working on a class library in .net, and am having a problem that I can only describe as a memory leak (which garbage collection was supposed to eliminate). My class library contains a single...
10
by: Flare | last post by:
Hi im trying to prevent people from useing more than one browser to view my page. But first i need to know excatly how static members of a form class is behaving. When is the IntanceCounter...
4
by: Mantorok | last post by:
Hi I have an ASP app which references a few static properties in some of the classes. I understand that you should use Session variables, but is it "possible" to have each session "not"...
2
by: james | last post by:
Hi I am considering storing my session variables within one static object with session scope. The static object will be a class with accessor functions to get and set the equivalent session...
1
by: cobus.lombard | last post by:
I have found it very easy to have a Helper class that has static members which access Session Variables. For example: public class HelperClass { public static doCustomer CurrentCustomer { get...
7
by: Spoon | last post by:
Hello everyone, I have a Packet class I use to send packets over the Internet. All the packets sent in a session are supposed to share a common random ID. I figured I'd use a static const...
2
by: BLUE | last post by:
FirstClass members: - static int counter; - SingletonClass sc = SingletonClass.Instance; Moreovere FirstClass uses a static class named SecondClass with a static property...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.