Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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.