Recall & Review
beginner
Why do variables in PHP not keep their values between different web requests?
Because each web request starts a new PHP process, variables are created fresh and lost when the script ends. PHP does not remember variable values automatically between requests.
Click to reveal answer
beginner
What happens to PHP variables after a web page finishes loading?
All PHP variables are destroyed when the script finishes running. The server forgets their values because PHP runs scripts from scratch on every request.
Click to reveal answer
intermediate
How can you keep data between PHP requests if variables do not persist?
You can use sessions, cookies, databases, or files to save data between requests. These methods store data outside the script so it can be reused later.
Click to reveal answer
intermediate
What is a session in PHP and how does it help with variable persistence?
A session stores data on the server linked to a user. It lets you save information like login status or preferences across multiple requests.
Click to reveal answer
intermediate
Explain why PHP is called a 'stateless' language in the context of web requests.
PHP is stateless because it does not remember anything from one request to the next. Each request is independent, so variables do not persist unless you use special storage methods.
Click to reveal answer
Why do PHP variables lose their values after a web request ends?
✗ Incorrect
PHP runs a new script for every request, so variables are reset each time.
Which method can you use to keep user data between PHP requests?
✗ Incorrect
Sessions store data on the server to keep it between requests.
What does it mean that PHP is 'stateless'?
✗ Incorrect
Stateless means no memory of previous requests unless you use storage like sessions.
When does PHP destroy all variables?
✗ Incorrect
Variables exist only during the script run and are destroyed after it finishes.
Which of these is NOT a way to keep data between PHP requests?
✗ Incorrect
Local variables only exist during one script run and do not persist.
Explain in your own words why PHP variables do not keep their values between web requests.
Think about what happens each time you reload a web page.
You got /4 concepts.
Describe at least two ways to save data between PHP requests and why they are needed.
How can PHP remember information about a user across pages?
You got /5 concepts.