0
0
PHPprogramming~5 mins

Script execution and memory reset in PHP - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What happens to variables in PHP after a script finishes executing?
All variables and data stored in memory during the script execution are cleared. PHP resets memory for the next script run.
Click to reveal answer
beginner
Why does PHP reset memory after each script execution?
To ensure each script runs fresh without leftover data, preventing unexpected behavior and improving security.
Click to reveal answer
beginner
Can data persist between PHP script executions without external storage?
No. PHP does not keep data in memory between runs. To persist data, you must use files, databases, or sessions.
Click to reveal answer
intermediate
How does PHP handle memory during script execution?
PHP allocates memory for variables and data as the script runs, then frees all memory when the script ends.
Click to reveal answer
intermediate
What is the role of the PHP garbage collector in script execution?
The garbage collector frees memory used by variables no longer referenced during script execution, helping manage memory efficiently.
Click to reveal answer
What happens to PHP variables after the script finishes?
AThey are saved automatically to a file
BThey stay in memory for the next script
CThey are cleared from memory
DThey become global variables
Which of these is needed to keep data between PHP script runs?
AUsing sessions or databases
BRelying on PHP memory reset
CDeclaring variables as static
DNothing, PHP keeps data automatically
When does PHP free memory used by variables?
AAt the end of script execution
BOnly when the server restarts
CWhen the user closes the browser
DNever, memory is permanent
What is the PHP garbage collector's job?
ASave variables to disk automatically
BPrevent script execution
CRestart the script if memory is low
DFree memory from unused variables during script run
Why is memory reset important in PHP script execution?
ATo keep data for the next user
BTo avoid leftover data causing bugs
CTo slow down the server
DTo save data automatically
Explain what happens to memory and variables when a PHP script finishes running.
Think about how PHP treats data after the script ends.
You got /3 concepts.
    Describe how you can keep data between PHP script executions despite memory reset.
    Memory reset means data disappears, so what tools help keep data?
    You got /4 concepts.