unset variable in php

前端 未结 5 1818
执念已碎
执念已碎 2021-01-11 16:16

I just read about unset variable through php manual.

The php manual says \"unset() destroys the specified variables\"

This def seems per

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-11 16:35

    Well, what unset() does is clears up the memory associated with a variable name.

    In the case of static variables, however, what you can visualize as happening is separating the static variable from the scope of the function, and every time you call the function, you automatically get a copy of that variable.

    So, what this means is if you unset a static variable, you are only actually unsetting that copy, so when the function is called again, it "receives" a fresh copy.

提交回复
热议问题