Should I use unset in php __destruct()?

2020-02-14 02:20发布

Is it a good practice to unset the variables that you used in a class? Or its an optional?

If its a good practice what is the benefit of using the unset function?

标签: php oop
1条回答
三岁会撩人
2楼-- · 2020-02-14 02:42

You really don't need to worry about cleaning up your variable declarations in PHP, its garbage collection takes care of all of that for you. Your __destruct() methods are primarily for things like closing persistent connections.

查看更多
登录 后发表回答