Jump to content

static, persistent objects in php


duomax

Recommended Posts

The problem is this, I want an object that different users can access. In java, this would be done with a singleton that all users can access. Now, it's important that all the users access the SAME object. Meaning, all the users aren't accessing an object of the same type, but the exact same object data and all.

 

Now, I looked up the singleton pattern for PHP, but it appears that the singleton created is only accessible to the current user and the object is collected after the page is generated. Is seems that the lifetime of all variable types ends after a page is generated.

 

My question is now, is there a way for an object to be shared by multiple users in PHP. Meaning, once one user tries to access the object it's created and then when future users try and get that object, they get the same one that was created. Thanks for your help in advance

Link to comment
https://forums.phpfreaks.com/topic/103420-static-persistent-objects-in-php/
Share on other sites

I was thinking it was impossible. But, quickly what exactly is an entity? I tried googling it, but didn't really get a decent result. I assume it means that each request is essentially in its own little sandbox, but something a little more technical would be nice. Thanks for the quick replies guys

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.