0

Does PHP have application memory like Java does or is it like a blank "memory" canvas for each stateless connection request (i.e. from each user)?

What I'm trying to confirm is, if I use a singleton pattern to hold data, is the instance ever shared between different users in PHP or would there be a different single instance created for each user?

If I use... $singInst = mySingleton::getInstance(); $singInst->holdA(5); $singInst->holdB(9); echo $singInst->getA();

Is the singleton ever shared between visiting users if required? i.e. call to singInst->getA() could return a value set from another user's script execution?

1
  • A singleton is single to a http request, it is not shared between multiple requests, so it cannot be set by one user's request and accessed by another user's request Commented Sep 15, 2014 at 15:21

1 Answer 1

2

every instance of PHP runs in it's own VM (virtual memory) which is separate from all other PHP processes VMs and mapped to physical memory by the OS, the PHP instance has the illusion of having access to the entire memory.

so no you cannot see another users singleton.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.