Home>Article>Backend Development> When are PHP variables released?

When are PHP variables released?

angryTom
angryTom Original
2019-10-29 17:19:24 3586browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn