473,657 Members | 2,477 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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::$checke r = new Checker();
}

function show() {
echo parent::$checke r->check(); <-- error !
}
}

Special::setChe cker ( );

$_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 1231

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

Similar topics

4
2558
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; public static string thisString = "This string value"; public static boolean thisBool = True .... if Class1 is never instantiated what value do these variables take on and
4
42020
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 datagrid paging. Can I use a static variable? Also, if I use a static variable is that variable shared by everyone that brings up the aspx page? Ex, if 4 people are viewing the aspx page is an instance of the static variable created for each of the...
1
2809
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 class, one member of which is a static SortedList of session data objects. One of my methods creates a new object on this list, and another removes the item from the list, which should make it eligible for garbage collection. I've tested this in...
10
1396
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 (see ***) desctructet?(reset) When the IIS server is restaret? Then Browser close? Im getting diffrent results everytime i try this.
4
2477
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" reference the same static members. For example if I update the static member on one session this change will be reflected on somebody elses session, which I don't want. I hope there's an easy solution for this as changing to session variables
2
2242
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 variables stored as member variables. This will allow strong typing. Apart from the problems of multithreading, are there any performance overheards of which I should be aware? Thanks
1
1617
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 { if(HttpContext.Current.Session == null)
7
4017
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 member inside my class. class Packet { static const int session_id;
2
1628
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 SecondClass.Description. In a normal windows application: - if in the Main method I create 2 or more instances of FirstClass, they all
0
8844
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8742
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8518
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8621
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7354
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2743
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1971
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1734
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.