Overview - Why variables do not persist between requests
What is it?
In PHP, variables are temporary storage spots that hold data while a script runs. Each time a web server handles a new request, it starts fresh and runs the PHP script from the beginning. This means any variables created during one request disappear once that request finishes. Variables do not automatically keep their values between different requests.
Why it matters
Without understanding this, beginners might expect data to stay saved automatically, leading to bugs and confusion. If variables did persist between requests, it would be like leaving your desk messy forever, making it hard to keep track of what belongs to which task. Knowing this helps you learn how to save data properly across visits, like using sessions or databases.
Where it fits
Before this, learners should know basic PHP syntax and how PHP scripts run on a server. After this, they will learn about sessions, cookies, and databases to store data between requests.