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.

PHP Build a Simple PHP Application Adding a Contact Form Working with Post Variables

Katya Neulinger
Katya Neulinger
13,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 :)

3 Answers

On the server. PHP is a server side language.

Katya Neulinger
Katya Neulinger
13,471 Points

thanks Ted. I am using MAMP, to start server on my local machine, then the data is stored somewhere on my computer, I am interested where exactly..

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:

https://teamtreehouse.com/forum/database-versus-array

Katya Neulinger
Katya Neulinger
13,471 Points

thanks! It was interesting to read.

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.