How does PHP handle memory allocation and deallocation during script execution?
PHP handles memory allocation and deallocation automatically during script execution using its built-in memory management system. When a variable is created, PHP allocates memory for it, and when the variable is no longer needed or goes out of scope, PHP automatically deallocates the memory. However, it is good practice to unset variables or objects that are no longer needed to free up memory explicitly.
// Example of explicit memory deallocation in PHP
$var = "Hello"; // Memory allocated for $var
unset($var); // Memory deallocated for $var