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
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.