Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Katya Neulinger13,471 Points
Where input data is stored?
When user enters name, email, ect. the data goes into $_POST array? right? But where this array is actually stored? Just curious :)
On the server. PHP is a server side language.
My understanding is that arrays are stored in RAM. If they are written to disk, it would be in either the server files or the PHP files.
I don't know whether user entered data will persist from session to session. If not, it is either in RAM or a temp file. So, I guess I don't know the answer. You may be interested in reading this post and answers:
The data is sent to the server through the request and loaded into specific global variables. So my guess is that the data is stored in the same way as any other variable, which would be in memory - just a best guess mind you!
Languages have a thing called 'garbage collection'. It's basically the removal of "things I don't need anymore". For instance, if you have a function, variables created and stored within the scope of the function. When the function completes, the scoped variables are no longer referenced (in use) and they get thrown away from memory - this is garbage collection.
If you load the request data into fixed variables within the global scope, they should be knocking around for the entire life cycle of the request.
I'm now going to go away and research this to see if this is what actually happens lol.