Home>Article>Backend Development> When are PHP variables released?
When are PHP variables released?
PHP variables are released after the program is executed.
If you are finished using it and want to destroy it, you can use unset to destroy and release
Example: unset($str);
unset and null
$var = null;This method only removes the reference, but does not actually release the memory. The unset method is PHP's built-in method of destroying variables and releasing memory.
But it should be noted that if the reference relationship of the variable referenced by unset(); is still there, then this memory will not be released for the time being. Only when all variables refer to this memory area This freed memory area will be released only after all references are broken.
For example:
Result:272
Result:192
For more PHP related knowledge, please visitPHP中文网!
The above is the detailed content of When are PHP variables released?. For more information, please follow other related articles on the PHP Chinese website!